<filename>lang/py/cookbook/v2/source/cb2_7_9_sol_1.py
import MySQLdb
# Create a connection object, then use it to create a cursor
con = MySQLdb.connect(host="127.0.0.1", port=3306, 
    user="joe", passwd="<PASSWORD>", db="tst")
cursor = con.cursor()
# Execute an SQL string
sql = "SELECT * FROM Users"
cursor.execute(sql)
# Fetch all results from the cursor into a sequence and close the connection
results = cursor.fetchall()
con.close()

<filename>lang/py/cookbook/v2/source/cb2_7_9_sol_1.py
import MySQLdb
# Create a connection object, then use it to create a cursor
con = MySQLdb.connect(host="127.0.0.1", port=3306, 
    user="joe", passwd="<PASSWORD>", db="tst")
cursor = con.cursor()
# Execute an SQL string
sql = "SELECT * FROM Users"
cursor.execute(sql)
# Fetch all results from the cursor into a sequence and close the connection
results = cursor.fetchall()
con.close()

# Create a connection object, then use it to create a cursor # Execute an SQL string # Fetch all results from the cursor into a sequence and close the connection