Compare commits

..

1 Commits

Author SHA1 Message Date
Jeffrey Paul 82d43af480 fixed undefined exclude_tables 2016-05-07 03:45:28 +02:00
3 changed files with 7 additions and 15 deletions

View File

@ -1,6 +1,7 @@
# sqlite2json
sqlite2json
======
This script dumps all\* the tables in an sqlite database as json.
This script dumps all* the tables in an sqlite database as json.
## Usage
@ -17,9 +18,3 @@ Here is a more useful version of the above example:
\*The script doesn't dump the contents of of the sqlite_master table
# Authors
* John Gerlock `<john@pikkey.com>`
* Jeffrey Paul `<sneak@sneak.berlin>`

View File

@ -2,8 +2,8 @@ from setuptools import setup
setup(
name='sqlite2json',
version='1.0.1',
author='John Gerlock',
version='1.0.0',
author='John gerlock',
author_email='john@pikkey.com',
packages=['sqlite2json'],
url='https://github.com/john-g-g/sqlite2json',

View File

@ -37,7 +37,7 @@ def sqlite2json(exclude_tables=None,db_file=None):
return json.dumps(get_tables(cursor))
def get_table_list(cursor, exclude_tables=set([])):
def get_table_list(cursor, exclude_tables=set([]):
cursor.execute('SELECT * FROM main.sqlite_master WHERE type="table"')
return set(row[1] for row in cursor.fetchall()) - exclude_tables
@ -52,10 +52,7 @@ def get_table(cursor, table_name):
def get_tables(cursor):
table_list = get_table_list(cursor)
output = {}
for table_name in table_list:
output[table_name] = get_table(cursor, table_name)
return output
return [{table_name : get_table(cursor, table_name) for table_name in table_list}]
if __name__ == "__main__":
main()