[Tutor] sqlite3 question

Alan Gauld alan.gauld at btinternet.com
Wed May 23 20:19:00 CEST 2012


On 23/05/12 17:11, Khalid Al-Ghamdi wrote:

> I'm using Python 3 and have read that you need sqlite to be installed to
> use the sqlite3 module, but when it is imported it seems to work ok.

The info is wrong.
Unlike other SQL databases SQLite is not a server based system so there 
is nothing to install. It is just a set of functions in a library, which 
comes with Python.

When you create a SQLite database it creates a file. All the tables and 
data are stored in that file. You can move your database to anotrher 
system just be copyting the file.

This makes SQLite great for small( <1GB) databases but also ultimately 
limits its scalability and performance...

> when you create the database where is it saved?

Wherever you want it to be, you just specify the filename when
creating it (or connecting to it). Either natively:

$ sqlite3 /home/ag/data/employee.db

or from Python:

db = sqlite.connect('/home/ag/data/employee.db')

See the database topic in my tutorial for some more extensive examples.

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list