Skip to content
Advertisement

Tag: postgresql

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 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

Advertisement