I Try to save a hashed Password in postgresql database using SQL Alchemy. table script is: and this is the mapping: when i try to insert data, this exception raised : but as you see data is exactly fit too field and there is no error when i execute this query inside pgadmin! I think problem is in my mapping.
Tag: psycopg2
Get the auto id for inserted row into Redshift table using psycopg2 in Python
I am inserting a record into a Amazon Redshift table from Python 2.7 using psycopg2 library and I would like to get back the auto generate primary id for the inserted row. I have tried the usual ways I can find here or in other websites using google search, eg: I receive an error on cur.execute line : Does anybody
Error Installing Psycopg2 on MacOS 10.9.5
I’m trying to install Psycopg2 on my Macbook, but I am getting an error. I found a lot of the same questions on StackOverflow but no answer seems to work. I’m using: OS: MacOS 10.9.5 Python Version: 3.4.3 My error code is: Answer I ran pip install psycopg2-binary and it worked like charm More info about the binary package Python
Creating transactions with with statements in psycopg2
I am trying to use psycopg2 to add some new columns to a table. PostgreSQL lacks a ALTER TABLE table ADD COLUMN IF NOT EXISTS, so I am adding each column in it’s own transaction. If the column exists, there will be a python & postgres error, that’s OK, I want my programme to just continue and try to add
Installing psycopg2 in a virtualenv in ubuntu os
I using a virtualenv and I am trying to set up postgresql. I have psycopg2 installed on my system, but it appears that my virtual env does not recognize psycopg2. Is it possible to just copy the system wide psycopg2 files into my django project directory or is this a bad approach to take? This is the relevant part of
query from postgresql using python as dictionary
I’m using Python 2.7 and postgresql 9.1. Trying to get dictionary from query, I’ve tried the code as described here: http://wiki.postgresql.org/wiki/Using_psycopg2_with_PostgreSQL It is printing the next answer: printing the item itself, show me that it is list. The excepted answer was dictionary. Edit: Trying the next: returns Answer If you don’t want to use a psycopg2.extras.DictCursor you can create a
Get psycopg2 count(*) number of results
Whats the correct way to get the number or rows returned by this query? I’m specifically looking to see if no results are returned. Thanks. Answer results is itself a row object, in your case (judging by the claimed print output), a dictionary (you probably configured a dict-like cursor subclass); simply access the count key: Because you used .fetchone() only
sqlalchemy.exc.ArgumentError: Can’t load plugin: sqlalchemy.dialects:driver
I am trying to run alembic migration and when I run It fails saying the database url is and I even have psycopg2 installed in my virtualenv Whay could be causing this issue? Answer Here’s how to produce an error like that: so I’d say you aren’t actually using the postgresql URL you think you are – you probably are
Is it possible to issue a “VACUUM ANALYZE ” from psycopg2 or sqlalchemy for PostgreSQL?
Well, the question pretty much summarises it. My db activity is very update intensive, and I want to programmatically issue a Vacuum Analyze. However I get an error that says that the query cannot be executed within a transaction. Is there some other way to do it? Answer This is a flaw in the Python DB-API: it starts a transaction
Making sure that psycopg2 database connection alive
I have a python application that opens a database connection that can hang online for an hours, but sometimes the database server reboots and while python still have the connection it won’t work with OperationalError exception. So I’m looking for any reliable method to “ping” the database and know that connection is alive. I’ve checked a psycopg2 documentation but can’t