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: …
Tag: postgresql
Django change database field from integer to CharField
I have a Django app with a populated (Postgres) database that has an integer field that I need to change to a CharField. I need to start storing data with leading zeros in this field. If I run migrate …
Django 1.8 inspectdb command doesn’t see PostgreSQL views as per documentation
I have a Django 1.8 application with a PostgreSQL database. I run the django inspectdb from the command line to examine models for the views, but the views don’t show up in the model output. Here’s …
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, …
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 …
Postgresql Database Backup Using Python
I would like to backup database using Python code. I want to backup some tables of related data. How to backup and how to choose desired tables using “SELECT” statement? e.g. I want to get data from 2014-05-01 to 2014-05-10 of some tables and output this result as .sql extension file How can I get this format using python code?
How to write DataFrame to postgres table?
There is DataFrame.to_sql method, but it works only for mysql, sqlite and oracle databases. I cant pass to this method postgres connection or sqlalchemy engine.
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 import psycopg2 …
How to find pg_config path
Complete newbie here, trying to set up Django to work with PostgreSQL. I’m using mac osx 10.6.8. I have also installed PostgreSQL 9.3 When I run pip install psycopg2 in terminal I get the following error I’ve seen a number of posts on this how-to-install-psycopg2-with-pip-on-python pg-config-executable-not-found but I have no clue how to find the bin folder location containing pg_config.
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