Skip to content

Commit 25a68d2

Browse files
author
James William Pye
committed
Update copyrights and update some documentation.
s,pg/python,James William Pye,g Being that pg/python *is* James William Pye, and the effective dissolution of using "pg/python project" anymore, I thought it best to substitute my name in. :( Hopefully this won't last, and contributors will inspire a generalization.
1 parent ad77c7f commit 25a68d2

45 files changed

Lines changed: 141 additions & 75 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
About py-postgresql
2+
===================
3+
4+
py-postgresql is a Python 3 package providing modules to work with PostgreSQL.
5+
This includes a high-level driver, and many other tools that support a developer
6+
working with PostgreSQL databases.
7+
8+
The goal of this project is to provide substantial convenience to developers
9+
working with PostgreSQL.
10+
11+
Installation
12+
------------
13+
14+
Installation should be as simple as::
15+
16+
$ python3.0 ./setup.py install
17+
18+
Further information is located in doc/install.txt.
19+
20+
Basic Driver Usage
21+
------------------
22+
23+
Using PG-API is recommended as it provides more utility for the user. However, a
24+
DB-API 2.0 driver is provided: `postgresql.driver.dbapi20`.
25+
26+
Sample PG-API Code
27+
^^^^^^^^^^^^^^^^^^
28+
29+
import postgreql.driver as pg_driver
30+
31+
# Alter the parameters accordingly
32+
db = pg_driver.connect(user = 'myuser', host = 'localhost', port = 5432, database = 'mydbname', password = 'secret')
33+
34+
# create a prepared statement
35+
get_table = db.query("select * from information_schema.tables where table_name = $1")
36+
for x in get_table("tables"):
37+
print(x)
38+
print(get_table.first("tables"))
39+
40+
41+
Further Information
42+
-------------------
43+
44+
The documentation directory, `doc`, contains more detailed information on the
45+
modules herein.

postgresql/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# copyright 2008, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""

postgresql/clientoptparse.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
# -*- encoding: utf-8 -*-
21
##
3-
# copyright 2008, pg/python project.
2+
# copyright 2009, James William Pye
43
# http://python.projects.postgresql.org
54
##
65
'PostgreSQL client optparse options'

postgresql/clientparams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# copyright 2007, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""

postgresql/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# copyright 2008, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""

postgresql/configfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# copyright 2008, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
'PostgreSQL configuration file parser and editor functions.'

postgresql/driver/__init__.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,24 @@
11
##
2-
# copyright 2009, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""
6-
6+
Driver package for connecting to PostgreSQL via a data stream(sockets).
77
"""
8+
from .driver.pq3 import Connector, Connection
9+
__all__ = ['Connector', 'Connection', 'connect']
10+
11+
_connectors = {}
12+
def connect(**kw):
13+
"""
14+
Create a PG-API connection using the given parameters.
15+
16+
See the `Connecting` section in the documentation for more information about
17+
suitable parameters.
18+
"""
19+
id = set(kw.items())
20+
c = _connectors.get(id)
21+
if c is None:
22+
c = Connector(**kw)
23+
_connectors[id] = c
24+
return c()

postgresql/driver/dbapi20.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
##
2-
# copyright 2007, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""
6-
DB-API 2.0 conforming interface on postgresql.driver.pgapi.
6+
DB-API 2.0 conforming interface using postgresql.driver
77
"""
88
threadsafety = 1
99
paramstyle = 'pyformat'
1010
apilevel = '2.0'
1111

12-
import postgresql.driver.pgapi as pg_driver
12+
import postgresql.driver as pg_driver
1313
import postgresql.types as pg_type
1414
import postgresql.strings as pg_str
1515
import datetime, time
@@ -213,12 +213,11 @@ def commit(self):
213213
def rollback(self):
214214
self.pg_api.xact.restart()
215215

216-
_connectors = {}
217216
def connect(**kw):
218-
kwi = kw.items()
219-
kwi.sort()
220-
kwi = tuple(kwi)
221-
con = _connectors.get(kwi)
222-
if not con:
223-
con = _connectors[kwi] = pg_driver.connector(**kw)
224-
return Connection(con())
217+
"""
218+
Create a DB-API connection using the given parameters.
219+
220+
See the `Connecting` section in the documentation for more information about
221+
suitable parameters.
222+
"""
223+
return Connection(pg_driver.connect(**kw))

postgresql/driver/pgapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# copyright 2008, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""

postgresql/driver/pythoncommand.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
##
2-
# copyright 2009, pg/python project.
2+
# copyright 2009, James William Pye
33
# http://python.projects.postgresql.org
44
##
55
"""

0 commit comments

Comments
 (0)