草庐IT

Psycopg2

全部标签

python - 安装 psycopg2 时出错,找不到 -lssl 的库

我跑sudopipinstallpsycopg2我得到一堆看起来像这样的输出:cc-DNDEBUG-g-fwrapv-Os..........cc-DNDEBUG-g-fwrapv-Os..........最后它说:ld:librarynotfoundfor-lsslclang:error:linkercommandfailedwithexitcode1(use-vtoseeinvocation)error:command'cc'failedwithexitstatus1----------------------------------------Cleaningup...Comma

python - psycopg2:用一个查询插入多行

我需要用一个查询插入多行(行数不是恒定的),所以我需要像这样执行查询:INSERTINTOt(a,b)VALUES(1,2),(3,4),(5,6);我知道的唯一方法是args=[(1,2),(3,4),(5,6)]args_str=','.join(cursor.mogrify("%s",(x,))forxinargs)cursor.execute("INSERTINTOt(a,b)VALUES"+args_str)但我想要一些更简单的方法。 最佳答案 我构建了一个程序,可以将多行插入到位于另一个城市的服务器中。我发现使用这种方法

python - DatabaseError : current transaction is aborted, 命令在事务 block 结束之前被忽略?

我收到了很多错误消息:"DatabaseError:currenttransactionisaborted,commandsignoreduntilendoftransactionblock"从python-psycopg更改为python-psycopg2作为Django项目的数据库引擎之后。代码保持不变,只是不知道那些错误来自哪里。 最佳答案 当查询产生错误并且您尝试运行另一个查询而不首先回滚事务时,这就是postgres所做的。(您可能会将其视为一项安全功能,以防止您破坏数据。)要解决此问题,您需要找出代码中执行错误查询的位置

python - DatabaseError : current transaction is aborted, 命令在事务 block 结束之前被忽略?

我收到了很多错误消息:"DatabaseError:currenttransactionisaborted,commandsignoreduntilendoftransactionblock"从python-psycopg更改为python-psycopg2作为Django项目的数据库引擎之后。代码保持不变,只是不知道那些错误来自哪里。 最佳答案 当查询产生错误并且您尝试运行另一个查询而不首先回滚事务时,这就是postgres所做的。(您可能会将其视为一项安全功能,以防止您破坏数据。)要解决此问题,您需要找出代码中执行错误查询的位置

python - 如何在 Python 上使用 "pip"安装 psycopg2?

我正在使用virtualenv,我需要安装“psycopg2”。我做了以下事情:pipinstallhttp://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160我收到以下消息:Downloading/unpackinghttp://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160Downl

python - 如何在 Python 上使用 "pip"安装 psycopg2?

我正在使用virtualenv,我需要安装“psycopg2”。我做了以下事情:pipinstallhttp://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160我收到以下消息:Downloading/unpackinghttp://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160Downl

python - 找不到 pg_config 可执行文件

我在安装psycopg2时遇到问题。当我尝试pipinstallpsycopg2时出现以下错误:Error:pg_configexecutablenotfound.Pleaseaddthedirectorycontainingpg_configtothePATHorspecifythefullexecutablepathwiththeoption:pythonsetup.pybuild_ext--pg-config/path/to/pg_configbuild...orwiththepg_configoptionin'setup.cfg'.-----------------------

python - 找不到 pg_config 可执行文件

我在安装psycopg2时遇到问题。当我尝试pipinstallpsycopg2时出现以下错误:Error:pg_configexecutablenotfound.Pleaseaddthedirectorycontainingpg_configtothePATHorspecifythefullexecutablepathwiththeoption:pythonsetup.pybuild_ext--pg-config/path/to/pg_configbuild...orwiththepg_configoptionin'setup.cfg'.-----------------------