python+sqlalchemy用法示例,注意配置makedsn挺关键,否则就会报各种错误,当然版本版本挺重要 import cx_Oracle from sqlalchemy import create_engine import os,time os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8' import pandas as pd ip = '127.0.0.1' port = '1521' uname = 'tcmp' # 用户名 pwd = '1234' # 密码 tnsname = 'orcl' # 实例名 dsnStr = cx_Oracle.makedsn(ip, port, service_name=tnsname) connect_str = "oracle://%s:%s@%s" %(uname, pwd, dsnStr) engine = create_engine(connect_str) sql = "SELECT * FROM T_GNLK_TEMP where rownum<=500000" df=pd.read_sql(sql,con=engine) print(df)
04-03
1126