Horje
python and mysql connectivity Code Example
connect python to mysql
import mysql.connector
mydb = mysql.connector.connect(
  host="localhost",
  user="yourusername",
  password="yourpassword",
  port = 8888, #for Mamp users
  database='whatever db you want'
)
print(mydb) 
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()
mysql connection python
from sqlalchemy import types, create_engine
import pymysql

try:
	conn = create_engine('mysql+pymysql://user:pass@IP/database_name')
  	print("MySQL Connection Sucessfull!!!!!!!!!!!")

except Exception as err:

	print("MySQL Connection Failed !!!!!!!!!!!")
	print(err)




Sql

Related
oracle object dependencies  Code Example oracle object dependencies Code Example
oracle gather table statistics Code Example oracle gather table statistics Code Example
test the postgresql db connection Code Example test the postgresql db connection Code Example
sql union Code Example sql union Code Example
sql query interview questions Code Example sql query interview questions Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7