sqlite3.OperationalError: near ".": syntax error

Lele Gaifax lele at metapensiero.it
Fri Sep 19 10:47:41 CEST 2014

luofeiyu <elearn2014 at gmail.com> writes:

> why " cur.execute('.tables')  "  can't  get output?

Most probably because that is not an SQL statement, but a command
implemented by the SQLite command line client.

To get the list of tables, the following may work for you:

>>> import sqlite3
>>> con = sqlite3.connect('development.db')
>>> cur = con.cursor()
>>> res = cur.execute("select * from sqlite_master where type='table'")
>>> print(list(res))
[('table', 'clubs', 'clubs', 2, 'CREATE TABLE clubs....)]

See http://www.sqlite.org/faq.html#q7 for details.

ciao, lele.
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
lele at metapensiero.it  |                 -- Fortunato Depero, 1929.

More information about the Python-list mailing list