-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.py
38 lines (26 loc) · 853 Bytes
/
db.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
35
36
37
38
import sqlite3
from sqlite3 import Error
def sql_connection():
try:
conn = sqlite3.connect('database.db')
print("Open database successfully..")
return conn
except Error:
print(Error)
def sql_table(conn):
#conn = conn.cursor()
conn.execute('''CREATE TABLE users (
Name TEXT Not Null,
Phone INTEGER Not Null Unique,
Email TEXT Not Null Unique,
Password TEXT Not Null
)''')
conn.commit()
print("Table created sucessfully..")
conn = sql_connection()
# sql_table(conn)
def sql_insert(conn, entities):
conn.execute('INSERT INTO users( Name, Phone, Email, Password) VALUES(?, ?, ?, ?)', entities)
conn.commit()
entities = ('Aditya', 9804138060,'[email protected]','Aditya31')
sql_insert(conn, entities)