-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_json.py
More file actions
22 lines (18 loc) · 861 Bytes
/
load_json.py
File metadata and controls
22 lines (18 loc) · 861 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import noteql
import click
@click.command()
@click.option('--path', default='', help='path to list in json')
@click.option('--table', default='', help='tablename')
@click.option('--schema', default='', help='schema')
@click.option('--field', default='', help='fieldname in table')
@click.option('--dburi', default='', help='sqlalchemy db uri')
@click.option('--append', is_flag=True, help='prefix')
@click.option('--overwrite', is_flag=True, help='overwrite')
@click.argument('file_name')
def load_json_command_line(file_name, path, table, schema, field, dburi, append, overwrite):
if not schema:
schema = 'public'
session = noteql.Session(schema, dburi=dburi)
session.load_json(file_name, path_to_list=path, table_name=table, field_name=field, append=append, overwrite=overwrite)
if __name__ == "__main__":
load_json_command_line()