Python 编程错误:(psycopg2.ProgrammingError)can';t适应类型';dict';
我正在尝试使用查询插入数据帧Python 编程错误:(psycopg2.ProgrammingError)can';t适应类型';dict';,python,json,postgresql,pandas,Python,Json,Postgresql,Pandas,我正在尝试使用查询插入数据帧 engine = create_engine('scot://pswd:xyz@ hostnumb:port/db_name') dataframe.to_sql('table_name', engine, if_exists='replace') 但是有一列是字典,我无法插入它,只插入了列名 我试图将postgres中的列类型从text更改为json对象。仍然无法插入 我尝试使用json.dumps(),但仍然面临问题。获取错误为“dtype:object
engine = create_engine('scot://pswd:xyz@ hostnumb:port/db_name')
dataframe.to_sql('table_name', engine, if_exists='replace')
但是有一列是字典,我无法插入它,只插入了列名我试图将postgres中的列类型从text更改为json对象。仍然无法插入
我尝试使用json.dumps(),但仍然面临问题。获取错误为“dtype:object is not json serializable”请尝试指定dtype。在你的例子中,你会说
dataframe.to_sql('table_name', engine, if_exists='replace',dtype =
{'relevant_column':sqlalchemy.types.JSON})
尝试指定数据类型。在你的例子中,你会说
dataframe.to_sql('table_name', engine, if_exists='replace',dtype =
{'relevant_column':sqlalchemy.types.JSON})