Share & Revise Any Time

Related Posts


List of All Python / MySQL / CSV Projects


Learn Python Programming


Watch Tutorial of Data Entry Project ( Recommended )

This project is covered in two parts

1. MySQL coding for creating database

2. Python coding for executing project


CREATE DATABASE IN MYSQL


import mysql.connector as a
con = a.connect(host="localhost",
              user="root",
              passwd="12345")
c = con.cursor()
sql1 = "create database dataentry"
c.execute(sql1)
sql2 = "use dataentry"
c.execute(sql2)
sql3 = "create table data (name varchar(50),phone varchar(20),email varchar(50),city varchar(20),date varchar(20))"
c.execute(sql3)
con.commit()

# Coding for Executing software/project

import mysql.connector as a
con = a.connect(host="localhost",user="root",passwd="12345",database="dataentry")

def enter():
    n = input(" Name : ")
    p = input(" Phone : ")
    yn = check(p)
    if yn == 'no':
        pass
    else:
        print("Data Already Exist")
        main()
    e = input(" Email : ")
    c = input(" City : ")
    d = input(" Date : ")
    dt = (n,p,e,c,d)
    sql = 'insert into data values(%s,%s,%s,%s,%s)'
    c = con.cursor()
    c.execute(sql,dt)
    con.commit()
    print("Data Entered Successfully")
    main()

def check(p):
    sql = 'select phone from data'
    c = con.cursor()
    c.execute(sql)
    for i in c:
        if i[0] == p:
            return "yes"
        else:
            pass
    return "no"

def fdata():
    sql = "select * from data"
    c = con.cursor()
    c.execute(sql)
    for i in c:
        print(i)
    main()
        
def main():
    print(" 1. Enter     2. Check    3. Full Data")
    ch = int(input(" Enter Choice : "))
    if ch == 1:
        enter()
    elif ch == 2:
        p = input(" Phone : ")
        d = check(p)
        if d == 'yes':
            print("Already Exist")
            main()
        else:
            main()
    elif ch == 3:
        fdata()
    else:
        print("Enter correct choice")
        main()
main()

Share & Revise Any Time