Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

python sqlite can't find db table

enter image description here

I am trying to run a python script which shows all data from a table named RANK.

The python script is located at /Downloads/pythonScript/dbCompare.py
I am trying to run it from /Downloads

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So I have tried to run the dbCompare.py script from /Downloads using python pythonScript/dbCompare.py 1300 and it is telling me that there is no RANK table.

After doing that, I changed my working directory from /Downloads to /Downloads/pythonScript then did it again, using python dbCompare.py 1300 command.
And it worked.

The reason why I am trying to run this command from /Downloads is I need to run this command from NodeJS server.

I also realized that after doing what I said, when I do ls command from /Downloads, an empty RANK.db file was generated newly. I don’t know why.

enter image description here

I have checked my db file if there is a typo or something else but I don’t see any.

How do I run this python script from /Downloads?

>Solution :

change the path in
sqlite3.connect(‘rank.db’) to sqlite3.connect(‘relative path\rank.db’)
that’s because of at the first connection python will search in the same dir of the script

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading