-
Notifications
You must be signed in to change notification settings - Fork 0
/
cli.py
36 lines (29 loc) · 652 Bytes
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import click
import pg
@click.group()
def cli():
pass
@cli.command()
def init():
"""
Run once to initialize database from CSV files.
"""
db = pg.Connector()
db.initialize_table("typed_posts")
db.initialize_table("typed_comments")
db.initialize_table("mbti9k")
db.initialize_table("unique_comments")
db.vacuum_analyze()
db.close()
@cli.command()
def summarize():
"""
Create all summary tables/views from script.
"""
db = pg.Connector()
script = "schema/summary_tables.sql"
db.execute_script(script)
db.connection.commit()
db.close()
if __name__ == "__main__":
cli()