1.连接mysql
import pymysql
# 1.连接数据库
client = pymysql.connect(
# 地址
host='127.0.0.1',
# 数据库端口
port=3306,
# 用户名,要加引号
user='root',
# 密码,要加引号
password='2694',
# 文件夹
database='db2',
# 设置字符编码不能写成了utf-8
charset='utf8',
# 设置自动提交命令,如不设置则无法提交命令进行增,改,删操作
autocommit=True
)
2.连接oracle
import cx_oracle
conn_str = {"userName": "abc", "password": "abc",
"host": "192.168.1.2:1521", "instance": "orcl"}
conn = cx_Oracle.connect("{}/{}/@{}/{}".format(conn_str["userName"],
conn_str["password"], conn_str["host"], conn_str["instance"]))
cursor = conn.cursor()
3.连接KingBaseES V8
用odbc