CYBER WEEK - EXTRA SAVINGS EVENT
TRY A FREE LESSON

Have problem connecting and reading database in gdrive

Screen Link: Google Colab

My Code:

import sqlite3
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from sklearn.cluster import KMeans
from sklearn.preprocessing import scale

from google.colab import drive
drive.mount(’/content/drive’)

cnx = sqlite3.connect(’/content/drive/My Drive/colab_apps/firstApp/database.sqlite’)
df = pd.read_sql_query(“SELECT * FROM Player_Attributes”, cnx)
df

What I expected to happen:
To display the data frame

What actually happened:
OperationalError Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1680 try:
→ 1681 cur.execute(*args, **kwargs)
1682 return cur

OperationalError: no such table: Player_Attributes

The above exception was the direct cause of the following exception:

DatabaseError Traceback (most recent call last)
3 frames
/usr/local/lib/python3.7/dist-packages/pandas/io/sql.py in execute(self, *args, **kwargs)
1691
1692 ex = DatabaseError(f"Execution failed on sql ‘{args[0]}’: {exc}")
→ 1693 raise ex from exc
1694
1695 @staticmethod

DatabaseError: Execution failed on sql ‘SELECT * FROM Player_Attributes’: no such table: Player_Attributes

How do I solve this?

Hi @jilly.koh:

You may find this useful: