GithubHelp home page GithubHelp logo

nad2000 / pg8000 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mfenniak/pg8000

0.0 1.0 0.0 754 KB

A Pure-Python PostgreSQL Driver

Home Page: http://pybrary.net/pg8000/

License: Other

Python 100.00%

pg8000's Introduction

PG8000

PG8000 is a pure-Python PostgreSQL driver that complies with DB-API 2.0. The driver communicates with the database using the PostgreSQL Backend / Frontend Protocol. The supported Python versions are:

  • CPython 2.5
  • CPython 2.6
  • CPython 2.7
  • CPython 3.2
  • CPython 3.3
  • PyPy
  • Jython 2.5

Usage

>>> import pg8000
>>> conn = pg8000.DBAPI.connect(user='postgres', password='password')

The connect function takes the following parameters:

parameter default
user
host localhost
unix_sock
port 5432
database
password
socket_timeout60
ssl False
>>> pg8000.DBAPI.paramstyle = 'numeric'
>>> cur = conn.cursor()
>>> cur.execute("create temporary table example (id int, name varchar)")
>>> cur.execute("insert into example values (1, 'hello')")
>>> conn.commit()
>>> cur.execute("select * from example where id = :1", (1,))
>>> for row in cur:
...     print(row)
[1, 'hello']
>>> cur.close()
>>> conn.commit()

Following the DB-API specification, autocommit is off by default. It can be turned on by using the autocommit property of the connection.

>>> conn.autocommit = True
>>> cur = conn.cursor()
>>> cur.execute("vacuum")
>>> conn.autocommit = False

Regression Tests

To run the regression tests, install tox:

pip install tox

then add install all the supported Python versions, and add a line to pg_hba.conf requiring md5 for the database pg8000_md5, eg.

host    pg8000_md5      all             127.0.0.1/32            md5

and run tox from the pg8000 directory:

tox

Performance Tests

To run the performance tests from the pg8000 directory:

python -m pg8000.tests.performance

pg8000's People

Contributors

mfenniak avatar repl-mathieu-fenniak avatar tlocke avatar zzzeek avatar reingart avatar nad2000 avatar ulope avatar etrepum avatar zeha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.