I would like to dump only one table but by the looks of it there is no parameter for this.
I found this example of the dump but is is for all tables:
# Convert file existing_db.db to SQL dump file dump.sql
import sqlite3, os
con = sqlite3.connect('existing_db.db')
with open('dump.sql', 'w') as f:
for line in con.iterdump():
f.write('%s\n' % line)
You can copy only the single table in an in memory db:
Pro: Simplicity and reliability: you don't have to re-write any library method, and you are more assured that the code is compatible with future versions of the sqlite3 module.
Con: You need to load the whole table in memory, which may or may not be a big deal depending on how big the table is, and how much memory is available.
Dump realization lies here http://coverage.livinglogic.de/Lib/sqlite3/dump.py.html (local path: PythonPath/Lib/sqlite3/dump.py)
You can modify it a little:
Now it accepts table name as second argument.
You can use it like this:
Will get something like:
By iterdump(), all information would be displayed like this:
An easy way is by filter certain keywords by string.startswith() method. For example, the table name is 'phone':
Not very smart, but can fit your objective.