recopytex/backend/adapters/sqlite.py

34 lines
603 B
Python
Raw Permalink Normal View History

2022-12-26 17:07:23 +00:00
import sqlite3
def create_tribe_table(conn) -> None:
cursor = conn.cursor()
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS tribes(
2022-12-26 18:21:00 +00:00
name VARCHAR PRIMARY KEY UNIQUE,
level VARCHAR
2022-12-26 17:07:23 +00:00
)
"""
)
conn.commit()
def create_student_table(conn) -> None:
cursor = conn.cursor()
cursor.execute(
"""
CREATE TABLE IF NOT EXISTS students(
id VARCHAR(500) PRIMARY KEY UNIQUE,
name VARCHAR,
tribe_name VARCHAR
)
"""
)
conn.commit()
2022-12-26 17:07:23 +00:00
def create_db(conn) -> None:
create_tribe_table(conn)
create_student_table(conn)