Compare commits

...

6 Commits

Author SHA1 Message Date
Jeffrey Paul 4031bbf751
Merge branch 'master' of github.com:john-g-g/sqlite2json
Signed-off-by: Jeffrey Paul <jp@eeqj.com>
2016-05-07 04:08:09 +02:00
Jeffrey Paul 26e4cc1063 version bump to 1.0.1, added me to authors 2016-05-07 04:07:21 +02:00
Jeffrey Paul 6a56b2c3b4 actually fixes #4 now 2016-05-07 04:05:52 +02:00
Jeffrey Paul c280150707 actually fixes #4 2016-05-07 03:59:16 +02:00
Jeffrey Paul 359bf4feb7 fixes #4 2016-05-07 03:53:27 +02:00
Jeffrey Paul 028ab5910b fixes #2 2016-05-07 03:52:03 +02:00
3 changed files with 15 additions and 7 deletions

View File

@ -1,7 +1,6 @@
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
@ -18,3 +17,9 @@ 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.0',
author='John gerlock',
version='1.0.1',
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=exclude_tables):
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,7 +52,10 @@ def get_table(cursor, table_name):
def get_tables(cursor):
table_list = get_table_list(cursor)
return [{table_name : get_table(cursor, table_name) for table_name in table_list}]
output = {}
for table_name in table_list:
output[table_name] = get_table(cursor, table_name)
return output
if __name__ == "__main__":
main()