-
-
Save parzibyte/b048baa079961e33eb92c35eec6fdc5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
DATABASE_NAME = "games.db" | |
def get_db(): | |
conn = sqlite3.connect(DATABASE_NAME) | |
return conn | |
def create_tables(): | |
tables = [ | |
"""CREATE TABLE IF NOT EXISTS games( | |
id INTEGER PRIMARY KEY AUTOINCREMENT, | |
name TEXT NOT NULL, | |
price REAL NOT NULL, | |
rate INTEGER NOT NULL | |
) | |
""" | |
] | |
db = get_db() | |
cursor = db.cursor() | |
for table in tables: | |
cursor.execute(table) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment