stuff
This commit is contained in:
34
6-bank-software/create_db.py
Normal file
34
6-bank-software/create_db.py
Normal file
@@ -0,0 +1,34 @@
|
||||
import sqlite3
|
||||
# import csv
|
||||
|
||||
conn = sqlite3.connect('bank_schema.png')
|
||||
|
||||
c = conn.cursor()
|
||||
|
||||
# c.execute("""drop table users;""")
|
||||
c.execute("""CREATE TABLE 'users' (
|
||||
id int,
|
||||
name varchar,
|
||||
username varchar,
|
||||
date_created date,
|
||||
permission int,
|
||||
PRIMARY KEY (id)
|
||||
)""")
|
||||
|
||||
# c.execute("""drop table accounts;""")
|
||||
c.execute("""CREATE TABLE 'accounts' (
|
||||
id int,
|
||||
account_number int,
|
||||
balance int,
|
||||
user_id int,
|
||||
PRIMARY KEY (id),
|
||||
FOREIGN KEY (user_id) references users(id)
|
||||
)""")
|
||||
|
||||
|
||||
with open ('bank_schema.png', 'r') as bank_schema:
|
||||
creader = csv.reader(bank_schema, delimiter = ',')
|
||||
column_names = creader.__next__()
|
||||
|
||||
conn.commit()
|
||||
c.close()
|
||||
Reference in New Issue
Block a user