How to define a db file for sqlite?

M

Muddy Coder

Hi Folks,

I just downloaded and installed pysqlite, and I can import sqlite3
smoothly. Then, I need to connect sqlite by syntax:

I wish the data will be stored into directory ---> adirectory, with a
file named in db. But I got kicked out with an error message as:

Unable to open database file

I wonder: does pysqlite open a database file db for me? Or, do I need
to create an empty file inside adirectory with my text editor? Anyway,
somebody please help me out here. After I can connect it, the rest
will be easy to go, thanks!

Muddy coder
 
J

John Machin

Hi Folks,

I just downloaded and installed pysqlite, and I can import sqlite3
smoothly. Then, I need to connect sqlite by syntax:


I wish the data will be stored into directory ---> adirectory, with a
file named in db. But I got kicked out with an error message as:

Unable to open database file

I wonder: does pysqlite open a database file db for me?

Yes, provided that "adirectory" exists and you have write permission.
It won't make a directory for you. Same applies to open('adirectory/
db', 'wb')

Ensure that adirectory exists, and try it again. If that fails, try
the open() -- you may get a more informative error message.
Or, do I need
to create an empty file inside adirectory with my text editor?

No. However, try that and remember what happens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top