diff --git a/pgwrap/__init__.py b/pgwrap/__init__.py index 2ede364..8d19a19 100644 --- a/pgwrap/__init__.py +++ b/pgwrap/__init__.py @@ -1,5 +1,4 @@ - -#from .db import connection +from .db import connection version = "0.8.1" __doc__ = """ @@ -13,17 +12,17 @@ This is not intended to provide ORM-like functionality, just to make it easier to interact with PostgreSQL from python code for simple use-cases and allow direct SQL access for more complex operations. - - The module wraps the excellent 'psycopg2' library and most of the + + The module wraps the excellent 'psycopg2' library and most of the functionality is provided by this behind the scenes. The module provides: * Simplified handling of connections/cursor * Connection pool (provided by psycopg2.pool) - * Cursor context handler - * Python API to wrap basic SQL functionality - * Simple select,update,delete,join methods extending the cursor + * Cursor context handler + * Python API to wrap basic SQL functionality + * Simple select,update,delete,join methods extending the cursor context handler (also available as stand-alone methods which create an implicit cursor for simple queries) * Query results as dict (using psycopg2.extras.DictCursor) @@ -77,7 +76,7 @@ [['PostgreSQL...']] The cursor context provides the following basic methods: - + execute - execute SQL query and return rowcount query - execute SQL query and fetch results query_one - execute SQL query and fetch first result @@ -107,15 +106,15 @@ update - SQL update delete - SQL delete - The methods can be parameterised to customise the associated query - (see db module for detail): + The methods can be parameterised to customise the associated query + (see db module for detail): + + where - 'where' clause as dict (column operators can be + specified using the colunm__operator format) - where - 'where' clause as dict (column operators can be - specified using the colunm__operator format) - where = {'name':'abc','status__in':(1,2,3)} - columns - list of columns to be returned - these can + columns - list of columns to be returned - these can be real columns or expressions. If spefified as a tuple the column is explicitly named using the AS operator @@ -137,7 +136,7 @@ returning - columns to return (string) - The methods are also available as standalone functions which create an + The methods are also available as standalone functions which create an implicit cursor object. Basic usage: @@ -175,11 +174,11 @@ Prepared statements can be created using the - connection.prepare(stmt,params,name,call_type) + connection.prepare(stmt,params,name,call_type) - stmt : prepared statement (with parameters identified + stmt : prepared statement (with parameters identified in the statement using the psql $1,$2... notation) - params : list of optional parameter types (usually not + params : list of optional parameter types (usually not needed - infered by psql) name : name for the prepared statement (usually autogenerated) @@ -214,7 +213,7 @@ instance of logging.Logger or a file-like object (supporting the write method). - The log message is generated using the self.logf function (called with + The log message is generated using the self.logf function (called with the cursor object as a parameter). By default this just returns the query string however can be customised as needed. A cursor.timestamp attribute is available to allow execution time to be tracked. @@ -230,7 +229,7 @@ * 0.1 19-10-2012 Initial import * 0.2 20-10-2012 Remove psycopg2 dep in setup.py * 0.3 20-10-2012 Remove hstore default for cursor - * 0.4 21-10-2012 Add logging support + * 0.4 21-10-2012 Add logging support * 0.5 22-12-2012 Refactor connection class / remove globals * 0.6 23-12-2012 Add support for prepared statements * 0.7 26-12-2012 Add callable prepared statements & named cursor