python连接oracle数据库mysql数据库

mysql连接:
下载python——mysql驱动
import mysql.connector as conn
db = conn.connect(host="localhost", user="root", passwd="password", db="databases")
cursor1 = db.cursor()
sql_query='select * from mit_aps where  id < 21'
cursor1.execute(sql_query)
cursor1.close()


oracle连接:
下载python——oracle驱动
import cx_Oracle
con = cx_Oracle.connect( "name", "password","TNS")
cursor = con.cursor()
sql = "insert into MIT_APS (id,ap_dn, cityid) values (2,'cn=ap60784,cn=sdgZh8La,cn=district10057,cn=jinzhong,cn=shanxi,c=cn',1007)"
cursor.execute(sql)
con.commit()
cursor.close()
con.close()

你可能感兴趣的:(oracle,mysql,python)