Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 错误:\将数据帧上载到红移时获取\列\信息()_Python_Sql_Pandas_Amazon Redshift_Etl - Fatal编程技术网

Python 错误:\将数据帧上载到红移时获取\列\信息()

Python 错误:\将数据帧上载到红移时获取\列\信息(),python,sql,pandas,amazon-redshift,etl,Python,Sql,Pandas,Amazon Redshift,Etl,我正在尝试使用to_sql函数将pandas数据帧直接上传到Redshift connstr = 'redshift+psycopg2://%s:%s@%s.redshift.amazonaws.com:%s/%s' % (username, password, cluster, port, db_name) def send_data(df, block_size=10000): engine = create_engine(connstr) with

我正在尝试使用
to_sql
函数将pandas数据帧直接上传到Redshift

connstr = 'redshift+psycopg2://%s:%s@%s.redshift.amazonaws.com:%s/%s' % 
          (username, password, cluster, port, db_name)

def send_data(df, block_size=10000):
    engine = create_engine(connstr)
    with engine.connect() as conn, conn.begin():
        df.to_sql(name='my_table_clean', schema='my_schema', con=conn, index=False, 
                  if_exists='replace', chunksize=block_size)
    del engine
my\u schema.my\u table\u clean
存在(但为空),并且使用
connstr
构建的连接也有效(通过相应的
检索\u数据
方法验证)。retrieve函数从my_表中提取数据,我的脚本使用pandas将其清除,以输出到my_表中

问题是,我一直遇到以下错误:

TypeError:\u get\u column\u info()正好接受9个参数(给定8个)

在执行
to_sql
功能期间

connstr = 'redshift+psycopg2://%s:%s@%s.redshift.amazonaws.com:%s/%s' % 
          (username, password, cluster, port, db_name)

def send_data(df, block_size=10000):
    engine = create_engine(connstr)
    with engine.connect() as conn, conn.begin():
        df.to_sql(name='my_table_clean', schema='my_schema', con=conn, index=False, 
                  if_exists='replace', chunksize=block_size)
    del engine
我似乎不知道是什么导致了这个错误。有人熟悉吗

使用

  • python 2.7.13
  • 熊猫0.20.2
  • sqlalchemy 1.2.0
注意:我正试图绕过S3->Redshift,因为我不想在我的bucket中为一个文件创建一个文件夹,而且这个脚本不符合我的整体ETL结构。我希望在创建原始my_表的ETL之后运行这个脚本