mysql db code example

Example 1: mean mysql

avg(column)

Example 2: what is mysql?

MySQL is an open source DBMS which is built, supported and distributed by MySQL(ORACLE).

Example 3: 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()

Example 4: MYSQL

GRANT CREATE ON *.* TO 'testuser'@'localhost';

Tags:

Sql Example