【问题标题】:Read ORCL table into Dask dataframe将 ORCL 表读入 Dask 数据帧
【发布时间】:2019-06-26 08:26:21
【问题描述】:

使用cx_Oracle 连接器读入pandas df 可以正常工作,例如:

import pandas as pd
import cx_Oracle

conn_str = u'username/password@host:port/service_name'
conn = cx_Oracle.connect(conn_str)
tablequery="select * from largetable where rownum <= 5000000"
pd_df = pd.read_sql(tablequery, conn)

但是试图将此表读入 Dask 数据帧...

import dask.dataframe as dd

sqlalchemy_uri_orcl = "oracle:////username:password@host:port//service_name" 

来自 here 的 uri,带有适用于 Windows 10 的转义字符和:

dask_df = dd.read_sql_table(table = tablequery, uri = sqlalchemy_uri_orcl, index = "IDX")

来自here的dd调用,产生以下错误:

Error message: DatabaseError: (cx_Oracle.DatabaseError) ORA-12545: Connect failed because target host or object does not exist

不转义uri中的'/',报错略有不同:

NoSuchTableError:

如果需要,不确定如何将 cx_Oracle 连接器传递给 dask 调用

谢谢

【问题讨论】:

    标签: python oracle pandas dask


    【解决方案1】:

    我不确定您的 URI 是否正确。在other answers 中,他们使用以下内容,我想这也适用于 Dask:

    host=hostname
    port=port
    sid='sid'
    user='username'
    password='password'
    sid = cx_Oracle.makedsn(host, port, sid=sid)
    
    uri = 'oracle://{user}:{password}@{sid}'.format(
        user=user,
        password=password,
        sid=sid
    )
    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-03-29
      • 2021-11-05
      • 2019-01-16
      • 1970-01-01
      • 2017-02-04
      • 1970-01-01
      • 2021-03-26
      相关资源
      最近更新 更多