Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to define a db file for sqlite?

Reply
Thread Tools

How to define a db file for sqlite?

 
 
Muddy Coder
Guest
Posts: n/a
 
      03-08-2009
Hi Folks,

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

>>>conn = sqlite3.connect('adirectory/db')


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
 
Reply With Quote
 
 
 
 
John Machin
Guest
Posts: n/a
 
      03-08-2009
On Mar 8, 6:32*pm, Muddy Coder <(E-Mail Removed)> wrote:
> Hi Folks,
>
> I just downloaded and installed pysqlite, and I can import sqlite3
> smoothly. Then, I need to connect sqlite by syntax:
>
> >>>conn = sqlite3.connect('adirectory/db')

>
> 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
About typedef -- define the function pointer or define function model? robin liu C Programming 3 04-21-2006 03:26 PM
#define _ and #define __ Brian Takita Ruby 0 01-23-2006 04:34 AM
How to define a define that defines some defines ? theotyflos C Programming 3 02-19-2004 05:07 PM
Define a class using an XML file? Jonah Olsson ASP .Net 0 08-07-2003 05:30 PM



Advertisments