Skip to main content

Yet another PostgreSQL database driver

Project description

Yet another Python PostgreSQL database driver.

Pure python or Cython http://cython.org/ accelaleted.

Requirements

Installation

It can install as package or module.

Install as a package

$ pip install -r requirements.txt
$ pip install minipg

Install as a module

$ pip install pytz
$ cd $(PROJECT_HOME)
$ wget https://github.com/nakagami/minipg/raw/master/minipg/minipg.py

Example

Query:

import minipg
conn = minipg.connect(host='localhost',
                    user='postgres',
                    password='secret',
                    database='database_name')
cur = conn.cursor()
cur.execute('select foo, bar from baz')
for r in cur.fetchall():
   print(r[0], r[1])
conn.close()

COPY TO:

import minipg
conn = minipg.connect(host='localhost',
                    user='postgres',
                    password='secret',
                    database='database_name')
f = open('foo.txt', 'bw')
conn.execute('COPY foo_table TO stdout', f)
f.close()
conn.close()

COPY FROM:

import minipg
conn = minipg.connect(host='localhost',
                    user='postgres',
                    password='secret',
                    database='database_name')
f = open('foo.txt', 'br')
conn.execute('COPY foo_table FROM stdin', f)
f.close()
conn.close()

Execute Query from a command line

$ python -m minipg -H pg_server -U user -W pass -D db_name <<EOS
> SELECT * FROM FOO
> EOS

or

$ echo 'SELECT * FROM FOO' | python -m minipg -H pg_server -U user -W pass -D db_name

or

$ python -m minipg -H pg_server -U user -W pass -D db_name -Q 'SELECT * FROM FOO'

Restrictions and Unsupported Features

  • Authentication METHOD only can ‘trust’ or ‘md5’ in pg_hba.conf.

  • Not full support for array data types.

  • Not support for prepared statements.

For MicroPython

See https://github.com/nakagami/micropg . It’s a minipg subset driver.

Project details


Download files

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

Source Distribution

minipg-0.6.1.tar.gz (12.8 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page