Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/317.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 编程错误:(psycopg2.ProgrammingError)can';t适应类型';dict';_Python_Json_Postgresql_Pandas - Fatal编程技术网

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})