Sqlite syntax

David M. Cooke cookedm+news at physics.mcmaster.ca
Mon May 17 16:42:15 EDT 2004


At some point, "firephreek" <firephreek at earthlink.net> wrote:

> Is there some documentation out there that actually lists the Sqlite
> syntax?

You mean the SQL dialect it speaks? http://sqlite.org/lang.html

> Or even better, one that crosses over and talks about how it works with
> python?

Like all the other DB interfaces. See the pysqlite homepage for specifics.

> Sqlite seems quite the nifty little thing, but for some reason, I can't
> seem to get a list of tables in my databases through a python
> prompt.  

>From http://sqlite.org/lang.html#createtable, all the tables are
listed in the sqlite_master table, so 

>>> import sqlite
>>> cx = sqlite.connect("db")
>>> cu = cx.cursor()
>>> cu.execute('''SELECT * FROM sqlite_master''')
[('table', 'TEST', 'TEST', 3, 'CREATE TABLE TEST (V VARCHAR, I INTEGER)')]

> And since the databases aren't 'centralized' there's no way of knowing
> what databases I have floating around is there?

Use 'ls' :-). Each database is a separate file.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke
|cookedm(at)physics(dot)mcmaster(dot)ca



More information about the Python-list mailing list