-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb.py
More file actions
24 lines (22 loc) · 830 Bytes
/
db.py
File metadata and controls
24 lines (22 loc) · 830 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
from sql import establish_connection
def create_tables():
connection = establish_connection()
with connection:
with connection.cursor() as cursor:
create_table_users = """
CREATE TABLE IF NOT EXISTS user (
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(45) NOT NULL,
nickname VARCHAR(45),
discordid VARCHAR(45) NOT NULL,
serverid VARCHAR(45) NOT NULL,
warn INT DEFAULT 0
)
"""
try:
cursor.execute(create_table_users)
print("[LOG] Tables was seccsessfuly created")
except Exception as e:
print("[ERROR]:", e)
if __name__ == "__main__":
create_tables()