Untitled
unknown
python
a year ago
1.8 kB
1
Indexable
Never
import sqlite3 conn = sqlite3.connect("UserData.db") #create cursor object to execute queries cursor = conn.cursor() createTable = " CREATE TABLE registerData ( Email varchar(255) NOT NULL, userName varchar(255) NOT NULL, Gender varchar(255) NOT NULL, countryCode int NOT NULL, City varchar(255) NOT NULL, FullName varchar(255) NOT NULL, password varchar(255) NOT NULL, phoneNumber varchar(255) NOT NULL, knowledge varchar(255) NOT NULL, PRIMARY KEY (userName) )" cursor.execute(createTable) cursor.execute("INSERT INTO registerData VALUES (\"nothing@gmail.com\", \"Usernamek\", \"Male\", 44, \"Haifa\", \"Rafael Abeshaus\", \"gjgj1264\", \"0586302184\", \"Self Study\")") cursor.execute("INSERT INTO registerData VALUES (\"nothing@gmail.com\", \"username2\", \"Male\", 44, \"Haifa\", \"Rafael Abeshaus\", \"gjgj1264\", \"0586302184\", \"Self Study\")") cursor.execute("INSERT INTO registerData VALUES (\"nothing@gmail.com\", \"username3\", \"Male\", 44, \"Haifa\", \"Rafael Abeshaus\", \"gjgj1264\", \"0586302184\", \"Self Study\")") cursor.execute("INSERT INTO registerData VALUES (\"nothing@gmail.com\", \"username4\", \"Male\", 44, \"Haifa\", \"Rafael Abeshaus\", \"gjgj1264\", \"0586302184\", \"Self Study\")") adminUsers = " CREATE TABLE adminUsers ( username varchar(255) NOT NULL, password varchar(255) NOT NULL, PRIMARY KEY (username) )" cursor.execute(adminUsers) cursor.execute("INSERT INTO adminUsers VALUES (\"rafael\", \"heyheyhey123\")") conn.commit() cursor.execute("SELECT * FROM adminUsers") data = cursor.fetchall() print(data) cursor.execute("SELECT * FROM registerData") data = cursor.fetchall() print(data) cursor.execute("SELECT * FROM registerData where userName=\"Not You! Error\"") data = cursor.fetchall() print(data) conn.close()