Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

python and mysql connectivity

import pymysql

############### CONFIGURE THIS ###################
# Open database connection
db = pymysql.connect("database_host","username","password","database_name")
##################################################

# prepare a cursor object using cursor() method
cursor = db.cursor()

# execute SQL query using execute() method.
cursor.execute("SELECT VERSION()")

# Fetch a single row using fetchone() method.
data = cursor.fetchone()
print ("Database version : {0}".format(data))

# disconnect from server
db.close()
Source by copitosystem.com #
 
PREVIOUS NEXT
Tagged: #python #mysql #connectivity
ADD COMMENT
Topic
Name
7+7 =