-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.old.py
31 lines (23 loc) · 903 Bytes
/
database.old.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
import sqlite3
class Database:
def __init__(self):
self.create_items_table()
self.create_users_table()
@classmethod
def create_users_table(cls):
connection = sqlite3.connect("data.db")
cursor = connection.cursor()
create_users_table = 'CREATE TABLE IF NOT EXISTS users (id INTEGER PRIMARY KEY, username text,password text)'
cursor.execute(create_users_table)
connection.commit()
connection.close()
print("Users table created")
@classmethod
def create_items_table(cls):
connection = sqlite3.connect("data.db")
cursor = connection.cursor()
create_items_table = 'CREATE TABLE IF NOT EXISTS items (id INTEGER PRIMARY KEY, name text, price float )'
cursor.execute(create_items_table)
connection.commit()
connection.close()
print("Items table created")