HOME/Articles/

mysql example connect (snippet)

Article Outline

Python mysql example 'connect'

Functions in program:

  • def end():

Modules used in program:

  • import mysql.connector as con

python connect

Python mysql example: connect

import mysql.connector as con

cnx = con.connect(    user='mvp', 
                    password='epidemiologia',
                    host='johnny.heliohost.org',
                    database='mvp_viral')

cursor = cnx.cursor()

def end():
    cursor.close()
    cnx.close()