所以这是我的目标:获取导入pgdb的.py文件,以便运行.
为此,据我所知,我需要PygreSql.
我安装了postgresql 9.4.4和python 2.7.9(带有源代码的Postgresql和带有网站正常下载的python).我找到了文件PyGreSQL.tar(版本4.1.1),并python setup.py build在提取的tar文件的目录中运行了该命令.我收到了消息Exception: pg_config tool is not available..我该怎么做才能解决这个问题?
提前致谢!
我在文档中看到您需要使用服务器端(“命名”)游标以避免一次将所有结果加载到内存中。但后来我发现服务器端游标不可重用。.execute你只能对它们做一个。(否则你会得到ProgrammingError: can't call .execute() on named cursors more than once。)
有什么方法可以获得可以重复使用的游标,但也不会立即将所有数据加载到内存中?
我愿意使用不同的 Postgres 驱动程序,如果它能让事情变得更简单、性能更高。我查看了 PyGreSQL,但它似乎比 Postgres 命名游标慢得多。
我正在尝试使用“ pip install pygresql”安装pygresql程序包,但出现错误:命令'gcc'失败,退出状态为1我已经尝试了很多方法,但是我仍然不明白为什么它不起作用
Collecting pygresql
Using cached PyGreSQL-5.0.3.tar.gz
Building wheels for collected packages: pygresql
Running setup.py bdist_wheel for pygresql ... error
Complete output from command /Users/paulinelanquetin/anaconda/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/y9/vbfql6394h3g6_4ldhwqzx1c0000gp/T/pip-build-s7kjrkvj/pygresql/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /var/folders/y9/vbfql6394h3g6_4ldhwqzx1c0000gp/T/tmpvvbd5puepip-wheel- --python-tag cp36:
running bdist_wheel
running build
running build_py
creating build
creating build/lib.macosx-10.7-x86_64-3.6
copying pg.py -> build/lib.macosx-10.7-x86_64-3.6
copying pgdb.py -> build/lib.macosx-10.7-x86_64-3.6
running build_ext
building '_pg' extension
creating build/temp.macosx-10.7-x86_64-3.6
gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/Users/paulinelanquetin/anaconda/include -arch x86_64 …Run Code Online (Sandbox Code Playgroud) 我有以下代码
pg_con = conns.con_to_pg()
cur = pg_con.cursor()
with open('up_md.csv', 'r') as f:
next(f) # Skip the header row.
tbl = 'bidba.upmeta'
cur.copy_from(f, tbl, 'csv', sep=',')
pg_con.commit()
Run Code Online (Sandbox Code Playgroud)
架构和表bidba.upmeta存在于我的 postgres 数据库中。无论我做什么,我都会收到消息:relation "bidba.upmeta" does not exist错误。
我试过用单引号、双引号、不带引号来写。没有任何帮助。我缺少什么?是不是方法有问题copy_from?
我正在virtualenv使用flask微框架和PostgreSQL数据库配置一个使用python开发的遗留web服务应用程序,该应用程序PyGreSQL 5.0.3用作连接数据库的依赖项.
我安装了PostgreSQL 9.6.1,我用它安装了:
brew install postgresql
我已经安装并使用Python 2.7
当我跑了
pip install -r requirements.txt
我收到此错误消息:
Running setup.py install for PyGreSQL ... error
Complete output from command /Users/user/Development/Projects/flask/ws/myenv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/t1/x7lrbmyd3lq0k8ngknwg1zx00000gn/T/pip-build-KjQgiU/PyGreSQL/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/t1/x7lrbmyd3lq0k8ngknwg1zx00000gn/T/pip-3lBp1N-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/Development/Projects/flask/ws/myenv/include/site/python2.7/PyGreSQL:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-intel-2.7
copying pg.py -> build/lib.macosx-10.12-intel-2.7
copying pgdb.py -> build/lib.macosx-10.12-intel-2.7
running build_ext
building '_pg' extension
creating build/temp.macosx-10.12-intel-2.7
cc -fno-strict-aliasing -fno-common …Run Code Online (Sandbox Code Playgroud) pygresql ×5
python ×4
postgresql ×3
macos ×1
pgdb ×1
pip ×1
psycopg2 ×1
python-3.x ×1
virtualenv ×1