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

= c.connect(host = "localhost", user = "root", password ="9.8.9.9.6.7.7.4.1.1.")
= b.cursor()
a.execute("use telephone_directory")
a.execute("select * from telephone_directory")
= 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

Popular posts from this blog

Automating Piano Tiles in Python Which is Damn easy!!!!!!!!

A SIMPLE GAME FOR A BEGINNER IN PYTHON WITH ONLY TWO MODULES