1

I'm looking to access the sqlite dot commands in pysql, particularly the

.tables
.schema
.import 

commands. However, when I try:

>>> db.execute(".tables")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
pysqlite3.dbapi2.OperationalError: near ".": syntax error

What is the syntax that allows this?

not a dupe explained in comment

Mittenchops
  • 18,633
  • 33
  • 128
  • 246
  • 1
    The `.tables` etc commands are built into the command line client of SQLite, but you can use the equivalent SQL statements to get at the schema information. Importing must be done manually. `SELECT sql FROM sqlite_master WHERE name='foo';`See https://stackoverflow.com/questions/4654762/how-can-one-see-the-structure-of-a-table-in-sqlite – Corion Jan 04 '19 at 16:57
  • Possible duplicate of [How can one see the structure of a table in SQLite?](https://stackoverflow.com/questions/4654762/how-can-one-see-the-structure-of-a-table-in-sqlite) – Corion Jan 04 '19 at 18:01
  • Not a dupe of that. I know how to do that with a select query. I was asking specifically for a variety of dot commands (not just .schema) which are more succinct – Mittenchops Jan 04 '19 at 18:04

1 Answers1

0

As @Corion said in his comment, the sqlite3 dot commands are a feature of the sqlite3 command-line utility only, not the SQL dialect supported by SQLite3. Therefore if you want to get the effect of running these commands in your own program, you have to actually implement those yourself using the publically available SQLite3 functions.

varro
  • 2,382
  • 2
  • 16
  • 24