Please help - stuck on Data Analysis with Python - Reading Data from Databases

I am trying to follow along with the video by using Colab.

I managed to open this notebook in Colab:
github/ine-rmotr-curriculum/RDP-Reading-Data-with-Python-and-Pandas/blob/master/unit-1-reading-data-with-python-and-pandas/lesson-11-reading-data-from-relational-databases/files/Lecture.ipynb

when I tried to run the command:

cur.execute('SELECT * FROM employees LIMIT 5;')

I got an error saying No such table

I then ran the following commands:

sql_query = 'SELECT name FROM sqlite_master WHERE type="table";'
cur.execute(sql_query)
print(cur.fetchall())

and got an empty []

I thought perhaps the Chinook database was corrupt so I deleted it and tried to upload it from the Github site but just get this:

I’ve tried reloading the notebook from Github but it no longer seems to have the chinook.db.

Please help

Well, I still see a chinook.db file in the github:

Asside from that, I copied the workbook to my Colab, copied the DB over, and was able to run the code without issue:

Only thing I can think is maybe the DB wasn’t fully or correctly installed, or maybe the code before this where it connected to the DB didn’t finish correctly or something.

Thank you for replying. I think I tried all that but still didn’t work. So, please could you tell me:
a) how did you start your Colab
b) what steps you took to copy the workbook to your Colab
c) what steps you took to copy the DB over

Many thanks

Sure, but I do want to say, I’m not very familiar with Colab. I used it for the Python classes here, but thats about it. Below is how I did it though.

a) I just go to colab.research.google.com to go to Colab. I’m automatically signed in.

b) I go to File → Open Notebook, selected GitHub at the top, entered the github username for the repository (“ine-rmotr-curriculum”), click search icon, selected the repository, then selected lesson 11 (the one you’re working on).

c) From the repository I linked above, click the DB file… as there is no preview it will just look blank, but you can select download to download the file locally. Once its downloaded locally, I just drag and drop it from my local folder to the colab:

That will allow you to work on the notebook, but its not a local copy, so you won’t be able to save anything. If you hit CTRL+S to save, it will pop up the below warning:

image

And from there you can save a copy to your Google Drive for you to work on. There is also options to save to your github or elsewhere under the File menu.

Hope that helps.

Oh, and I found out if you want kittens or other things walking around on your menu bar, its under Tools → Settings… Under Miscellaneous

Thanks. I tried your steps and got the following:

Notice the red circle at the bottom

I don’t know what else to do

BTW, if I try these steps in my Command Prompt Python, they work!!

Yeah, I’m at a loss, but do believe it has something to do with this:

image

Maybe indicating that the chinook.db was not getting fully uploaded. Seems to work for you locally so the DB file is downloaded to your system correctly, but maybe something in Colab isn’t allowing the upload, firewall maybe, browser issue(could try another browser) or maybe you didn’t wait long enough for it to finish uploading. (For me the upload only took like 10 seconds though)

Sadly I’m at a loss aside from maybe those suggestions… all I could really atest to is what I did and that it worked for me.

Thanks. I’ve been using Firefox. I then tried with Edge and it worked :slight_smile: so I guess the problem lies with Firefox. I looked at settings but couldn’t see anything helpful. Do you have any suggestions that I could try to get Firefox working. If not, I’ll just use Edge for this

Not really. I use Firefox Dev Edition and it worked. Clear cache and cookies would be my only suggestion as a just in case. I don’t know of anything else that might prevent file upload.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.