-
Notifications
You must be signed in to change notification settings - Fork 0
/
db_init.py
43 lines (38 loc) · 1.08 KB
/
db_init.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
37
38
39
40
41
42
43
import sqlite3
USER_TABLE = """
CREATE TABLE IF NOT EXISTS user (
id int NOT NULL UNIQUE PRIMARY KEY,
first_name varchar(255),
last_name varchar(255),
username varchar(255),
creation_datatime datetime
)
"""
OPINION_TABLE = """
CREATE TABLE IF NOT EXISTS opinion (
id INTEGER NOT NULL UNIQUE PRIMARY KEY AUTOINCREMENT,
user_id int,
message text,
creation_datatime datetime,
FOREIGN KEY(user_id) REFERENCES user(id)
)
"""
"""
ALTER TABLE poemsnd DROP COLUMN filepath;
ALTER TABLE poemsnd RENAME COLUMN description to title
ALTER TABLE poemsnd RENAME COLUMN isdirect to audio_order
ALTER TABLE poemsnd RENAME COLUMN syncguid to artist
ALTER TABLE poemsnd RENAME COLUMN fchksum to telegram_file_id
ALTER TABLE poemsnd RENAME COLUMN isuploaded to recitation_type
"""
"""
ALTER TABLE fav DROP COLUMN pos;
ALTER TABLE fav RENAME COLUMN verse_id to user_id
"""
def init_database():
connection = sqlite3.connect('ganjoor.s3db')
cursor = connection.cursor()
cursor.execute(USER_TABLE)
cursor.execute(OPINION_TABLE)
connection.commit()
cursor.close()