-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
34 lines (28 loc) · 843 Bytes
/
database.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
32
33
34
#Database Management Banking
import mysql.connector as sql
mydb = sql.connect(
host="localhost",
user="root",
passwd="998133",
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()