-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsetup db.py
41 lines (35 loc) · 847 Bytes
/
setup db.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
# Configuring the database
import sqlite3
# Used for deleting the file
import os
# Create the connection
conn = sqlite3.connect('timezones.sql')
# Create the "timezones" table
conn.execute("""
CREATE TABLE IF NOT EXISTS timezones (
user_id INTEGER NOT NULL UNIQUE,
utc_diff INTEGER NOT NULL DEFAULT 0
);
""")
conn.commit()
# Create the "messages table"
conn.execute("""
CREATE TABLE IF NOT EXISTS messages (
guild_id INTEGER NOT NULL UNIQUE,
channel_id INTEGER NOT NULL UNIQUE,
count INTEGER NOT NULL DEFAULT 0
);
""")
# Create the "guilds" table - necessary for pagination.
conn.execute("""
CREATE TABLE IF NOT EXISTS guilds (
user_id INTEGER NOT NULL,
guild_id INTEGER NOT NULL,
PRIMARY KEY (user_id, guild_id)
);
""")
conn.commit()
# Close the connection
conn.close()
# Delete this file
os.remove(__file__)