Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions mysql-python.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import mysql.connector
import pyautogui

mypasswd=pyautogui.prompt('Enter your mysql password')
mydb=mysql.connector.connect(host='localhost', user='root', password=mypasswd)
cur=mydb.cursor()
cur.execute('create database if not exists rdm123')

mydb1=mysql.connector.connect(host='localhost',
user='root',
password=mypasswd,
database='rdm123')
cur1=mydb1.cursor()
cur1.execute('create table if not exists abc(number int(2) primary key not null auto_increment, name varchar(20), gender varchar(1))')

name=pyautogui.prompt('Enter Name')
gender=pyautogui.prompt('Enter Gender')

print(name)

if name!=None or gender!=None:
data1=(name,gender)
cur1.execute('insert into abc(name , gender) values (%s,%s)',data1)
mydb1.commit()
pyautogui.alert('Data Filled Successfully.')
else:
pyautogui.alert('Data Filling Cancelled')

show=pyautogui.confirm(text='Would you like to show the databases?', buttons=['Yes','No'])

if show == 'Yes':
cur1.execute('select * from abc')
shwd=cur1.fetchall()
pyautogui.alert(shwd)
print('SUCCED!')
else:
print('NOT SUCCED!')