Update of /cvsroot/pypgsql/pypgsql
In directory usw-pr-cvs1:/tmp/cvs-serv14948
Modified Files:
README
Log Message:
03NOV2002 bga Added information about the new PgArray class.
Index: README
===================================================================
RCS file: /cvsroot/pypgsql/pypgsql/README,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** README 27 Oct 2002 03:43:07 -0000 1.26
--- README 3 Nov 2002 20:39:55 -0000 1.27
***************
*** 1460,1463 ****
--- 1460,1467 ----
that fall within this class.
+ :PgArray: This class provide support for PostgreSQL arrays. It is a
+ wrapper around a Python list that supports all the methods of
+ a list plus adds a __quote__ method for quoting arrays.
+
3. The following class is defined:
***************
*** 1576,1585 ****
a new transaction is created on the next call to execute().
! If a PostgreSQL array (represented by a Python list) is the only parameter to
! a query, then it must be passed in a singleton tuple. For example::
! cnx.query('insert into table values(%s)', (list,))
When working with PostgreSQL large object, you MUST be in a transaction.
--- 1580,1602 ----
a new transaction is created on the next call to execute().
+ PostgreSQL arrays are no longer (directly) represented by Python lists. Ths
+ means that lists and tuples are not longer treated specially by
+ Cursor.execute(). This resolve a problem of using the IN SQL syntax with
+ Cursor.execute(). For example, the following statement will now work:
! Cursor.execute('select * from table where column1 in %s', ((1, 3, 4),))
! It will generate the following SQL statement:
!
! select * from table where column1 in (1, 3, 4)
+ It also means that to insert an PostgreSQL array, you must pass a PgArray
+ instance to Cursor.execute(). For example, if you have a list that you
+ want to insert into a table as a PostgreSQL array, you would use:
+
+ cursor.execute('insert in sometable values (%s)', PgArray(yourlist))
+
+ You can also build a PostgreSQL array by creating an empty PgArray instance
+ and populating it using the various list methods (.append(), .insert(), etc.).
When working with PostgreSQL large object, you MUST be in a transaction.
|