import pymysql
con=pymysql.connect(user='root',passwd='system',host='127.0.0.1',port=3306,database='mysql')
c=con.cursor()
c.execute("SELECT VERSION()")
data=c.fetchone()
print("Database version :%s"%data)
'''
# Create table as per requirement
sql = """CREATE TABLE EMPLOYEE (
         FIRST_NAME  CHAR(20) NOT NULL,
         LAST_NAME  CHAR(20),
         AGE INT,  
         SEX CHAR(1),
         INCOME FLOAT )"""

c.execute(sql)
con.close()


# Prepare SQL query to INSERT a record into the database.
sql = """INSERT INTO EMPLOYEE(FIRST_NAME,
         LAST_NAME, AGE, SEX, INCOME)
         VALUES ('Mac', 'Mohan', 20, 'M', 2000)"""
try:
   # Execute the SQL command
   c.execute(sql)
   # Commit your changes in the database
   con.commit()
except:
   # Rollback in case there is any error
   con.rollback()

# disconnect from server
con.close()
'''
sql = "SELECT * FROM EMPLOYEE \
       WHERE INCOME > '%d'" % (1000)
try:
   # Execute the SQL command
   c.execute(sql)
   # Fetch all the rows in a list of lists.
   results = c.fetchall()
   for row in results:
      fname = row[0]
      lname = row[1]
      age = row[2]
      sex = row[3]
      income = row[4]
      # Now print fetched result
      print ("fname=%s,lname=%s,age=%d,sex=%s,income=%d" % \
             (fname, lname, age, sex, income ))
except:
   print ("Error: unable to fecth data")

# disconnect from server
con.close()

189b664959d08c843682ca0d8d043fdeb1ce9370
<mask token>

<mask token>
c.execute('SELECT VERSION()')
<mask token>
print('Database version :%s' % data)
<mask token>
try:
    c.execute(sql)
    results = c.fetchall()
    for row in results:
        fname = row[0]
        lname = row[1]
        age = row[2]
        sex = row[3]
        income = row[4]
        print('fname=%s,lname=%s,age=%d,sex=%s,income=%d' % (fname, lname,
            age, sex, income))
except:
    print('Error: unable to fecth data')
con.close()

<mask token>
con = pymysql.connect(user='root', passwd='system', host='127.0.0.1', port=
    3306, database='mysql')
c = con.cursor()
c.execute('SELECT VERSION()')
data = c.fetchone()
print('Database version :%s' % data)
<mask token>
sql = "SELECT * FROM EMPLOYEE        WHERE INCOME > '%d'" % 1000
try:
    c.execute(sql)
    results = c.fetchall()
    for row in results:
        fname = row[0]
        lname = row[1]
        age = row[2]
        sex = row[3]
        income = row[4]
        print('fname=%s,lname=%s,age=%d,sex=%s,income=%d' % (fname, lname,
            age, sex, income))
except:
    print('Error: unable to fecth data')
con.close()

import pymysql
con = pymysql.connect(user='root', passwd='system', host='127.0.0.1', port=
    3306, database='mysql')
c = con.cursor()
c.execute('SELECT VERSION()')
data = c.fetchone()
print('Database version :%s' % data)
<mask token>
sql = "SELECT * FROM EMPLOYEE        WHERE INCOME > '%d'" % 1000
try:
    c.execute(sql)
    results = c.fetchall()
    for row in results:
        fname = row[0]
        lname = row[1]
        age = row[2]
        sex = row[3]
        income = row[4]
        print('fname=%s,lname=%s,age=%d,sex=%s,income=%d' % (fname, lname,
            age, sex, income))
except:
    print('Error: unable to fecth data')
con.close()

import pymysql
con=pymysql.connect(user='root',passwd='system',host='127.0.0.1',port=3306,database='mysql')
c=con.cursor()
c.execute("SELECT VERSION()")
data=c.fetchone()
print("Database version :%s"%data)
'''
# Create table as per requirement
sql = """CREATE TABLE EMPLOYEE (
         FIRST_NAME  CHAR(20) NOT NULL,
         LAST_NAME  CHAR(20),
         AGE INT,  
         SEX CHAR(1),
         INCOME FLOAT )"""

c.execute(sql)
con.close()


# Prepare SQL query to INSERT a record into the database.
sql = """INSERT INTO EMPLOYEE(FIRST_NAME,
         LAST_NAME, AGE, SEX, INCOME)
         VALUES ('Mac', 'Mohan', 20, 'M', 2000)"""
try:
   # Execute the SQL command
   c.execute(sql)
   # Commit your changes in the database
   con.commit()
except:
   # Rollback in case there is any error
   con.rollback()

# disconnect from server
con.close()
'''
sql = "SELECT * FROM EMPLOYEE \
       WHERE INCOME > '%d'" % (1000)
try:
   # Execute the SQL command
   c.execute(sql)
   # Fetch all the rows in a list of lists.
   results = c.fetchall()
   for row in results:
      fname = row[0]
      lname = row[1]
      age = row[2]
      sex = row[3]
      income = row[4]
      # Now print fetched result
      print ("fname=%s,lname=%s,age=%d,sex=%s,income=%d" % \
             (fname, lname, age, sex, income ))
except:
   print ("Error: unable to fecth data")

# disconnect from server
con.close()
