Compare commits
6 Commits
sneak-patc
...
master
Author | SHA1 | Date | |
---|---|---|---|
4031bbf751 | |||
26e4cc1063 | |||
6a56b2c3b4 | |||
c280150707 | |||
359bf4feb7 | |||
028ab5910b |
11
README.md
11
README.md
@ -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
|
## 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
|
\*The script doesn't dump the contents of of the sqlite_master table
|
||||||
|
|
||||||
|
# Authors
|
||||||
|
|
||||||
|
* John Gerlock `<john@pikkey.com>`
|
||||||
|
|
||||||
|
* Jeffrey Paul `<sneak@sneak.berlin>`
|
||||||
|
4
setup.py
4
setup.py
@ -2,8 +2,8 @@ from setuptools import setup
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='sqlite2json',
|
name='sqlite2json',
|
||||||
version='1.0.0',
|
version='1.0.1',
|
||||||
author='John gerlock',
|
author='John Gerlock',
|
||||||
author_email='john@pikkey.com',
|
author_email='john@pikkey.com',
|
||||||
packages=['sqlite2json'],
|
packages=['sqlite2json'],
|
||||||
url='https://github.com/john-g-g/sqlite2json',
|
url='https://github.com/john-g-g/sqlite2json',
|
||||||
|
@ -37,7 +37,7 @@ def sqlite2json(exclude_tables=None,db_file=None):
|
|||||||
|
|
||||||
return json.dumps(get_tables(cursor))
|
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"')
|
cursor.execute('SELECT * FROM main.sqlite_master WHERE type="table"')
|
||||||
return set(row[1] for row in cursor.fetchall()) - exclude_tables
|
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):
|
def get_tables(cursor):
|
||||||
table_list = get_table_list(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__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user