【问题标题】:pandas to_sql with Exasol熊猫 to_sql 与 Exasol
【发布时间】:2020-07-05 19:21:41
【问题描述】:

当我使用 to_sql 将数据帧上传到 exasol 并指定 if_exists='replace' 时,默认的字符串数据类型是 'text',Exasol 不支持。我认为 Varchar 是正确的类型。如何让 to_sql 使用 Varchar 而不是 Text 创建表?

【问题讨论】:

    标签: pandas exasolution exasol


    【解决方案1】:

    我知道这不是你所要求的 100%,但我建议使用 pyexasol 包在 Pandas 和 Exasol 之间进行通信。删除并跟随上传然后像

    import pyexasol
    import _config as config
    
    # Connect with compression enabled
     C = pyexasol.connect(dsn=config.dsn, user=config.user, 
     password=config.password, schema=config.schema,
                     compression=True)
    
    C.execute('TRUNCATE TABLE users_copy')
    
    
    # Import from pandas DataFrame into Exasol table
    C.import_from_pandas(pd, 'users_copy')
    
    stmt = C.last_statement()
    print(f'IMPORTED {stmt.rowcount()} rows in 
    {stmt.execution_time}s')
    C.close()
    

    不会出现 varchar 的问题。

    【讨论】:

      猜你喜欢
      • 2015-01-02
      • 2017-10-12
      • 1970-01-01
      • 2014-09-26
      • 1970-01-01
      • 2017-10-19
      • 2019-07-16
      • 1970-01-01
      • 2012-10-04
      相关资源
      最近更新 更多