HOME/Articles/

mysql example mysql-test (snippet)

Article Outline

Python mysql example 'mysql-test'

Modules used in program:

  • import mysql.connector

python mysql-test

Python mysql example: mysql-test

import mysql.connector

cnx = mysql.connector.connect(user='user', password='pass',
                              host='127.0.0.1')



cursor = cnx.cursor()

query = "SELECT company_name, company_mail, company_state FROM scrapped_mails"

cursor.execute(query)

for (company_name, company_mail, company_state) in cursor:
  print("{}, {} - {}")

cursor.close()
cnx.close()
print("Done with myseldibs.py")