Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

A psycopg2 wrapper using pandas DataFrame to perform CRUD operations with PostgreSQL

Project Description

Installation

pip install pypostgres

Not tested in python 2.x

Usage

>>> from pypostgres import Postgres

# Database connection
# Params: database, user, password=None, host='localhost', port=5432
>>> db = Postgres('dbname', 'user',)

# Execute query
>>> db.query('SELECT * FROM dbname;', mode='read')
>>> [(1, 99, "def'abc"), (2, 100, "abc'def")]

# Insert query
>>> db.query('INSERT INTO dbname (a, b) VALUES (%s, %s);', (1, 2), mode='write')
# return None

# DataFrame query
>>> db.to_dataframe(['id', 'num', 'data'], 'dbname', conditions="num > 1")
>>>
    id    num       data
0  2.0  100.0  "abc'def"

# Inserting a DataFrame
>>> import pandas as pd
>>> df = pd.DataFrame([(3, 98, 'test')], columns=['id', 'num', 'data'])
>>> db.from_dataframe(df, 'dbname')
# return None
Release History

Release History

This version
History Node

0.4

History Node

0.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pypostgres-0.4-py3-none-any.whl (5.5 kB) Copy SHA256 Checksum SHA256 3.5 Wheel Jun 14, 2016
pypostgres-0.4.tar.gz (16.1 kB) Copy SHA256 Checksum SHA256 Source Jun 14, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting