-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclt
35 lines (24 loc) · 971 Bytes
/
clt
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
#! /usr/bin/env python
import sqlite3
import os
from tabulate import tabulate
from src.database.ensure_db import ensure_langdb
from src.database.utils import print_table_from_cursor
from src.utils import get_arguments
def scratch():
print(tabulate([["value1", "value2"], ["value3", "value4"]], ["column 1", "column 2"], tablefmt="grid"))
def main():
ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) # This is your Project Root
print('<------- inside: main ------->')
con = sqlite3.connect('{path}/langbase.sqlite'.format(path=ROOT_DIR))
con.execute("PRAGMA foreign_keys = 1")
cur = con.cursor()
arguments = get_arguments()
ensure_langdb(con, cur)
arguments.term_split = arguments.term.split(' ')
query = "SELECT * FROM term_matches WHERE term IN (%s)" % ','.join('?' * len(arguments.term_split))
cur.execute(query, arguments.term_split)
print_table_from_cursor(cur)
con.commit()
con.close()
main()