DASK read_sql_table错误: 'instancemethod' 对象有没有属性 '__getitem__'
问题描述:
我得到这个错误与此PARAMS:DASK read_sql_table错误: 'instancemethod' 对象有没有属性 '__getitem__'
import pandas as pd
import numpy as np
from sqlalchemy import create_engine
import dask.dataframe as dd
from sqlalchemy.sql import text
query = text("Some SQL statement")
df = dd.read_sql_table(table=query,uri='Some postgreSQL DB',index_col='id')
息率这样的错误:
/usr/local/lib/python2.7/dist-packages/dask/dataframe/io/sql.pyc in read_sql_table(table, uri, index_col, divisions, npartitions, limits, columns, bytes_per_chunk, **kwargs)
73 schema=schema)
74
---> 75 index = (table.columns[index_col] if isinstance(index_col, six.string_types)
76 else index_col)
77 if not isinstance(index_col, six.string_types + (elements.Label,)):
TypeError: 'instancemethod' object has no attribute '__getitem__'
有人知道有什么问题?
答
的table
参数必须是现有的表(和因此是一个字符串或一sa.Table
实例)或全SQLAlchemy的声明(例如,sqlalchemy.sql.select()
),其中定义的完整的一组列的要被取出。原因是,我们不试图解析这里的通用查询,这可能是后端特定的。您可以利用sqlalchemy自己将文本查询转换为此函数的结构化语句。
'read_sql_table'作为第一个参数'table' - 一个字符串:'name_of_the_table'。您正在传递SQL查询而不是表名。 – Primer