How do I get a list of column names from a psycopg2 cursor?
I would like a general way to generate column labels directly from the selected column names, and recall seeing that python’s psycopg2 module supports this feature. 11 Answers 11
I would like a general way to generate column labels directly from the selected column names, and recall seeing that python’s psycopg2 module supports this feature. 11 Answers 11
I need to insert multiple rows with one query (number of rows is not constant), so I need to execute query like this one: INSERT INTO t (a, b) VALUES (1, 2), (3, 4), (5, 6); The only way I know is args = [(1,2), (3,4), (5,6)] args_str=”,”.join(cursor.mogrify(“%s”, (x, )) for x in args) cursor.execute(“INSERT … Read more
I use SQLAlchemy and there are at least three entities: engine, session and connection, which have execute method, so if I e.g. want to select all records from table I can do this engine.execute(select([table])).fetchall() and this connection.execute(select([table])).fetchall() and even this session.execute(select([table])).fetchall() – the results will be the same. As I understand it, if someone uses … Read more
I got a lot of errors with the message : “DatabaseError: current transaction is aborted, commands ignored until end of transaction block” after changed from python-psycopg to python-psycopg2 as Django project’s database engine. The code remains the same, just don’t know where those errors are from. 21 Answers 21
I’m using virtualenv and I need to install “psycopg2”. I have done the following: pip install http://pypi.python.org/packages/source/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160 And I have the following messages: Downloading/unpacking http://pypi.python.org/packages/source/p/psycopg2/psycopg2 -2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160 Downloading psycopg2-2.4.tar.gz (607Kb): 607Kb downloaded Running setup.py egg_info for package from http://pypi.python.org/packages/sou rce/p/psycopg2/psycopg2-2.4.tar.gz#md5=24f4368e2cfdc1a2b03282ddda814160 Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or specify … Read more
I am having trouble installing psycopg2. I get the following error when I try to pip install psycopg2: Error: pg_config executable not found. Please add the directory containing pg_config to the PATH or specify the full executable path with the option: python setup.py build_ext –pg-config /path/to/pg_config build … or with the pg_config option in ‘setup.cfg’. … Read more