How can I search an entire database in Python's sqlite3? -
new sqlite3... have constructed database in python using sqlite3. database has hundreds of tables. sample table lists, say, average age of people function of latitude , longitude. command can use search entire database (all tables) "avg. age" values lat > 15, , lon < 30? sample tables follows:
table 1:
_avg. age_|__latitude__|__longitude__ 15 | 19.86 | 21.5 21 | 19.86 | 21.5 75 | 19.86 | 21.5 16 | 19.86 | 21.5 . | . | . . | . | . . | . | . table 2:
_avg. age_|__latitude__|__longitude__ 75 | -22.65 | 53.5 65 | -22.65 | 53.5 12 | -22.65 | 53.5 31 | -22.65 | 53.5 16 | 19.86 | 53.5 . | . | . . | . | . . | . | .
you need iterate on tables , select each one
for table in db.execute("select name my_db.sqlite_master type='table'").fetchall(): print db.execute("select * %s lat > 15 , lon < 30"%table).fetchall() i guess
Comments
Post a Comment