-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdatabase.py
More file actions
34 lines (28 loc) · 841 Bytes
/
database.py
File metadata and controls
34 lines (28 loc) · 841 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
25
26
27
28
29
30
31
32
33
34
#Database Management Banking
import mysql.connector as sql
mydb = sql.connect(
host="localhost",
user="root",
passwd="7877",
database="bank"
)
cursor = mydb.cursor()
def db_query(str):
cursor.execute(str)
result = cursor.fetchall()
return result
def createcustomertable():
cursor.execute('''
CREATE TABLE IF NOT EXISTS customers
(username VARCHAR(20) NOT NULL,
password VARCHAR(20) NOT NULL,
name varchar(20) NOT NULL,
age INTEGER NOT NULL,
city VARCHAR(20) NOT NULL,
balance INTEGER NOT NULL,
account_number INTEGER NOT NULL,
status BOOLEAN NOT NULL)
''')
mydb.commit()
if __name__ == "__main__":
createcustomertable()