MY FIRST MYSQL PROJECT I EVER MADE
FIRST FILE CODE:
import mysql.connector as connector
ab = 0
asking = int(input("How many numbers you actually want to add: "))
if asking == 0:
pass
quit()
else:
while ab < asking:
asking -= 1
name = input("Enter The name you want to add: ")
number = int(input("Enter the number you want to add: "))
a = connector.Connect(host="localhost", user = "root",
password = "9.8.9.9.6.7.7.4.1.1.")
cur = a.cursor()
#cur.execute("show databases")
#results = cur.fetchall()
#cur.execute("create database telephone_directory")
cur.execute("use telephone_directory")
#cur.execute("create table telephone_directory(name char(200),
# numbers bigint(12))")
cur.execute(f"insert into telephone_directory values('{name}',{number})")
cur.execute("select * from telephone_directory")
e = cur.fetchall()
for i in e:
print(e)
#for c in results:
# print(c)
#cur.execute("select * from telephone_directory")
#e = cur.fetchall()
#for i in e:
# print(e)
SECOND FILE CODE:
import mysql.connector as c
b = c.connect(host = "localhost", user = "root", password ="9.8.9.9.6.7.7.4.1.1.")
a = b.cursor()
a.execute("use telephone_directory")
a.execute("select * from telephone_directory")
e = a.fetchall()
print(e)
MYSQL WORKBENCH CODE I USED:
#show databases;
#drop database telephone;
#create database telephone;
#use telephone;
#create table telephone(name char(200), numbers bigint(12));
#select * from telephone;
#insert into telephone values('aman', 9899677411);
Comments
Post a Comment