psycopg2

I am executing n no. of processes where n is could be between 5 - 50. Each process is making multiple dml operations on postgres

醉酒当歌 提交于 2020-01-22 02:30:32
问题 The processes would be running 24*7 and will be re-started periodically (like once in a week). In this case which is a better option : Opening a postgres connection per processes which will persist until the life of the process. Opening a postgres connection pool and sharing it among the processes. 回答1: The main objective is that there are not too many PostgreSQL connections at the same time, otherwise the danger increases that toi many of them will become active at the same time, thereby

xcrun/lipo freezes with OS X Mavericks and XCode 4.x

懵懂的女人 提交于 2020-01-19 04:46:09
问题 Been trying to install psycopg2 with either easy_install or pip, and the terminal gets stuck in a loop between xcrun and lipo. sidwyn$ sudo easy_install psycopg2 Searching for psycopg2 Reading https://pypi.python.org/simple/psycopg2/ Reading http://initd.org/psycopg/ Reading http://initd.org/projects/psycopg2 Best match: psycopg2 2.5.1 Downloading https://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.5.1.tar.gz#md5=1b433f83d50d1bc61e09026e906d84c7 Processing psycopg2-2.5.1.tar.gz

How do I translate PostgreSQL OID using python

末鹿安然 提交于 2020-01-17 08:31:35
问题 I am having bit of trouble with the psycopg2 Python module. I wrote a small code to extract some information from PostgreSQL table using psycopg2 module. I want to know the data type for each columns in the table: import os, psycopg2, getpass, sys, string userpass = getpass.getpass() # Connect to the database conn = psycopg2.connect("host=hostname dbname=db user=username password=%s" % (userpass)) cur = conn.cursor() cur.execute("SELECT * FROM database.table;") fieldTypes = [desc[1] for desc

Got widnows error 1120 while trying to install psycopg2/psycopg2-binary

妖精的绣舞 提交于 2020-01-16 01:18:08
问题 error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\BIN\\link.exe' failed with exit status 1120 I have installed postgresql and added to the global variables path to pg_config. Windows 8, python 3.8 回答1: Make sure you have python 3.8 64bit installed for 64bit machine and python 3.8 32bit for 32bit machine. Uninstalling old 32bit python and installing 3.8 64 bit for my 64 bit os worked for me to resolve the same issue. 来源: https://stackoverflow.com/questions/58638460/got

installing psycopg2 on Windows xp using pip and virtualenv

被刻印的时光 ゝ 提交于 2020-01-15 12:23:19
问题 I'm following Heroku's "Getting started with Django on Heroku" article and am getting a long series of errors on "pip install psycopg2". Django 1.5.1 and PostgreSQL 9.2.4 are already installed, and yes, the postgres \bin\, \include\ directories are on the PATH. C:\Python27\Scripts> C:\Python27\Scripts>cd C:\Projects\hellodjango C:\Projects\hellodjango>pip install psycopg2 Downloading/unpacking psycopg2 Downloading psycopg2-2.5.1.tar.gz (684kB): 684kB downloaded Running setup.py egg_info for

Converting query results into DataFrame in python

对着背影说爱祢 提交于 2020-01-15 06:05:10
问题 I am trying to perform manipulation on the result from a query using psycog2. Thus I have to covert result into pandas DataFrame. But when i use the following code and print, only the columns name are printed not the rows. I used 'pd.DataFrame.from_records' too but that did not work. import psycopg2 import pandas as pd import numpy as np conn_string = "Connect_Info" conn = psycopg2.connect(conn_string) cursor = conn.cursor() cursor.execute(query) rows=pd.DataFrame(cursor.fetchall(),columns=[

Effective query with multiple conditions

时光总嘲笑我的痴心妄想 提交于 2020-01-14 05:49:13
问题 I have a database with books (primary key: bookID) characterNames (foreign key: books.bookID) locations (foreign key: books.bookID) The in-text-position of character names and locations are saved in the corresponding tables. Now I want to write a Python script using psycopg2 to find all occurrences of a given character name and a given location in books, where both occur. At the moment, I execute 4 queries: SELECT bookID, position FROM characterNames WHERE name='XXX'; --> result is saved in

Python 3.7 psycopg2 - Xcode Error “error: command 'gcc' failed with exit status 1”

帅比萌擦擦* 提交于 2020-01-14 03:45:27
问题 For a Python/ Kivy project I'm working on at the moment (using PyCharm), I set up a postgreSQL database. When I try to install the psycopg2 adapter using the terminal $ pip install psycopg2 I am getting the error "error: command 'gcc' failed with exit status 1". The only thing that worked so far was installing the Binary from PyPI $ pip install psycopg2-binary . For running the project in PyCharm it works fine, since I could add psycopg2 and psycopg2-binary to my interpreter. But when I now

Error when installing psycopg2 on Windows 10

会有一股神秘感。 提交于 2020-01-13 10:49:06
问题 Collecting psycopg2 Using cached psycopg2-2.6.1.tar.gz Complete output from command python setup.py egg_info: running egg_info creating pip-egg-info\psycopg2.egg-info writing pip-egg-info\psycopg2.egg-info\PKG-INFO writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt' warning: manifest_maker: standard file '-c' not found Error: pg

Install libpq-dev on Mac OS X

柔情痞子 提交于 2020-01-12 00:51:43
问题 I'm trying to run Django with a Postgresql backend on my local Mac OS X. I've installed Django using pip: sudo pip install Django I've installed Postgresql with one of the binary installers here. But when I try to install psycopg2 I get an error (pasted below) that it can't find pg_config. From this question it seems like I should install libpq-dev but I'm not sure how. I've tried installing libpqxx with MacPorts, but that hasn't done anything. How do I get libpg-dev installed? Or is there