Skip to content

Commit

Permalink
nothing special in database
Browse files Browse the repository at this point in the history
  • Loading branch information
linrakesh committed Jul 29, 2019
1 parent c88dcc7 commit 2e50619
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions database/database_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,46 +11,52 @@

import MySQLdb


def show_records():
db= MySQLdb.connect("localhost","root","ramji","cable")
db = MySQLdb.connect("localhost", "root", "ramji", "cable")
cursor = db.cursor()
sql ="select * from customer"
sql = "select * from customer"
cursor.execute(sql)
results = cursor.fetchall()
for idr,name,fname,add,phone,email in results:
print(idr,name,fname,phone,email)
for idr, name, fname, add, phone, email in results:
print(idr, name, fname, phone, email)
db.close()


def del_record():
db= MySQLdb.connect("localhost","root","ramji","cable")
db = MySQLdb.connect("localhost", "root", "ramji", "cable")
cursor = db.cursor()
name = input("Enter name you want to delete")
sql ="delete from customer where name like '%" + name +"'%"
sql = "delete from customer where name like '%" + name + "'%"
cursor.execute(sql)
db.commit();
db.close();
db.commit()
db.close()
print("Record Deleted successfully")


def update_record():
db= MySQLdb.connect("localhost","root","ramji","cable")
db = MySQLdb.connect("localhost", "root", "ramji", "cable")
cursor = db.cursor()
email = input("Admin ID :")
sql ="update customer set email = 'admin@binarynote.com where email like '%" + email +"'%"
sql = "update customer set email = 'admin@binarynote.com where email like '%" + email + "'%"
cursor.execute(sql)
db.commit();
db.close();
db.commit()
db.close()
print("Record Updated successfully")


def main():
n=1
while n!=4:
n = 1
while n != 4:
n = int(input("Enter any no (1..3) "))
print(n)
if n==1:
if n == 1:
show_records()
if next==2:
if next == 2:
del_record()
if next==3:
if next == 3:
update_record()


if __name__ == '__main__':
main()
main()

0 comments on commit 2e50619

Please sign in to comment.