-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinit.py
More file actions
34 lines (30 loc) · 728 Bytes
/
init.py
File metadata and controls
34 lines (30 loc) · 728 Bytes
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
#!/usr/bin/env python3
import sqlite3
# read environment variables
with open('.env', 'r') as f:
for line in f:
key, val = line.strip().split('=')
globals()[key] = val
# connect sqlite
connection = sqlite3.connect(DB_NAME, check_same_thread=True)
cursor = connection.cursor()
# create tables
cursor.execute(
"CREATE TABLE IF NOT EXISTS 'group' ("
"'id' INTEGER PRIMARY KEY,"
"'group_id' TEXT,"
"'group_name' TEXT,"
"'group_title' TEXT,"
"'user_count' INTEGER)"
)
cursor.execute(
"CREATE TABLE IF NOT EXISTS 'user' ("
"id INTEGER PRIMARY KEY,"
"user_id TEXT,"
"is_bot BOOLEAN,"
"name TEXT,"
"username TEXT)"
)
# commit
connection.commit()
connection.close()