clickhouse
from sqlalchemy.engine import create_engine
import pandas as pd
ch_engine=create_engine('clickhouse://172.xx.x.xx:8xxx/audience')
pd.read_sql('show tables',ch_engine)
mysql
import MySQLdb
mysql_conf = {
'host': '172.xx.x.x',
'user': 'usersxx',
'password': 'xxxx',
'database': 'xxx',
'charset': 'utf8'
}
mysql_engine = MySQLdb.connect(**mysql_conf)
sq1='''show tables;'''
df2=pd.read_sql(sq1,mysql_engine)
df2
pgsql
写执行的语句
import psycopg2
conn = psycopg2.connect(dbname='xxx', user='xxx', password='xxx', host='172.xx.xx.xx', port='xxxx')
cur = conn.cursor()
sql='copy ......' # 写执行语句
cur.execute(sql)
conn.commit()
写查找的语句
import psycopg2
conn = psycopg2.connect(dbname='xxx', user='xxx', password='xxx', host='172.xx.xx.xx', port='xxxx')
cur = conn.cursor()
cur.execute('select xxx from xxx')
rows = cur.fetchall()
https://www.cnblogs.com/geo-will/p/9534732.html