You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(52) |
Oct
(21) |
Nov
(10) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(3) |
Feb
(7) |
Mar
|
Apr
(8) |
May
(1) |
Jun
(6) |
Jul
(4) |
Aug
(4) |
Sep
(18) |
Oct
(26) |
Nov
(7) |
Dec
(25) |
2003 |
Jan
(1) |
Feb
|
Mar
(1) |
Apr
(1) |
May
(1) |
Jun
(10) |
Jul
(10) |
Aug
|
Sep
|
Oct
(5) |
Nov
(2) |
Dec
(2) |
2004 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2005 |
Jan
|
Feb
(1) |
Mar
(8) |
Apr
(1) |
May
(3) |
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(11) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Gerhard H?r. <gha...@us...> - 2003-07-10 16:05:34
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv791 Modified Files: README Log Message: 10JUL2003 gh Added paragraph about the Unicode related parameters of the connect function. Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** README 5 Dec 2002 05:34:30 -0000 1.30 --- README 10 Jul 2003 15:36:19 -0000 1.31 *************** *** 1599,1602 **** --- 1599,1639 ---- way to get the object ID of a newly inserted record. + 2.2.5 Unicode support + --------------------- + + pyPgSQL has a few extensions that make it possible to insert Unicode strings + into PostgreSQL and fetch unicode strings instead of byte strings from the + database. + + The module-level connect() function has two Unicode-related parameters: + + - client_encoding + - unicode_results + + *client_encoding* accepts the same parameters as the encode method + of Unicode strings. If you also want to set a policy for encoding + errors, set client_encoding to a tuple, like ("koi8-r", "replace") + + Note that you still must make sure that the PostgreSQL client is + using the same encoding as set with the client_encoding parameter. + This is typically done by issuing a "SET CLIENT_ENCODING TO ..." + SQL statement immediately after creating the connection. + + If you also want to fetch Unicode strings from the database, set + *unicode_results* to 1. + + For example, assuming a database created with *createdb mydb -E UNICODE* and a + table *TEST(V VARCHAR(50))*: + + >>> from pyPgSQL import PgSQL + >>> cx = PgSQL.connect(database="mydb", client_encoding="utf-8", unicode_results=1) + >>> cu = cx.cursor() + >>> cu.execute("set client_encoding to unicode") + >>> cu.execute("insert into test(v) values (%s)", (u'\x99sterreich',)) + >>> cu.execute("select v from test") + >>> cu.fetchone() + [u'\x99sterreich'] + >>> + ================================== 3.0 General Notes and Observations |
From: Billy G. A. <bal...@us...> - 2003-06-27 03:03:11
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv5827/pyPgSQL Modified Files: PgSQL.py Log Message: 26JUN2003 bga - Applied patch from Laurent Pinchart to allow _quote to correctly process objects that are sub-classed from String and Long types. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** PgSQL.py 17 Jun 2003 01:49:24 -0000 1.33 --- PgSQL.py 27 Jun 2003 03:03:08 -0000 1.34 *************** *** 30,33 **** --- 30,36 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 26JUN2003 bga - Applied patch from Laurent Pinchart to allow _quote | + # to correctly process objects that are sub-classed | + # from String and Long types. | # 05JUN2003 bga - Change the name of the quoting function back to | # _quote. Variables named like __*__ should be restrict | *************** *** 2243,2249 **** elif type(value) is DateTimeDeltaType: return "'%s'" % dateTimeDelta2Interval(value) ! elif type(value) is StringType: return PgQuoteString(value) ! elif type(value) is LongType: return str(value) else: --- 2246,2252 ---- elif type(value) is DateTimeDeltaType: return "'%s'" % dateTimeDelta2Interval(value) ! elif isinstance(value, StringType): return PgQuoteString(value) ! elif isinstance(value, LongType): return str(value) else: *************** *** 2593,2597 **** "Unlink of large object failed - Connection is not open." ! if self.version.post70 or not self.inTransaction: raise NotSupportedError, \ "unlink of a PostgreSQL Large Object in a transaction" --- 2596,2600 ---- "Unlink of large object failed - Connection is not open." ! if not self.version.post70 and self.inTransaction: raise NotSupportedError, \ "unlink of a PostgreSQL Large Object in a transaction" |
From: Billy G. A. <bal...@us...> - 2003-06-27 03:01:22
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv5725 Modified Files: pgconnection.c Log Message: 26JUN2003 bga Fixed a bug I introduced into lo_import. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** pgconnection.c 17 Jun 2003 01:35:45 -0000 1.18 --- pgconnection.c 27 Jun 2003 03:01:20 -0000 1.19 *************** *** 29,32 **** --- 29,33 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 26JUN2003 bga Fixed a bug I introduced into lo_import. | | 15JUN2003 bga Applied patch by Laurent Pinchart to correct a problem | | lo_import, lo_export, lo_unlink. | *************** *** 963,967 **** return (PyObject *)NULL; ! if ((oid = lo_import(PgConnection_Get(self), filename)) < 0) { PyErr_SetString(PqErr_OperationalError, "Can't import large object."); --- 964,968 ---- return (PyObject *)NULL; ! if ((oid = lo_import(PgConnection_Get(self), filename)) <= 0) { PyErr_SetString(PqErr_OperationalError, "Can't import large object."); |
From: Billy G. A. <bal...@us...> - 2003-06-17 01:49:27
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv7227/pyPgSQL Modified Files: PgSQL.py Log Message: 05JUN2003 bga - Change the name of the quoting function back to _quote. Variables named like __*__ should be restrict to system names. 02JUN2003 bga - PgTypes is now hashable. repr() of a PgType will now return the repr() of the underlying OID. - Connection.binary() will now fail if autocommit is enabled. - Connection.binary() will no longer commit the transaction after creating the large object. The application developer is now responsible for commiting (or for rolling back) the transaction [Bug #747525]. - Added PG_TIMETZ to the mix [Patch #708013]. - Pg_Money will now accept a string as a parameter. - PostgreSQL int2, int, int4 will now be cast into Python ints. Int8 will be cast into a Python long. Float4, float8, and money types will be cast into a Python float. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** PgSQL.py 7 Mar 2003 06:24:39 -0000 1.32 --- PgSQL.py 17 Jun 2003 01:49:24 -0000 1.33 *************** *** 30,33 **** --- 30,50 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 05JUN2003 bga - Change the name of the quoting function back to | + # _quote. Variables named like __*__ should be restrict | + # to system names. | + # 02JUN2003 bga - PgTypes is now hashable. repr() of a PgType will now | + # return the repr() of the underlying OID. | + # - Connection.binary() will now fail if autocommit is | + # enabled. | + # - Connection.binary() will no longer commit the trans- | + # action after creating the large object. The applica- | + # tion developer is now responsible for commiting (or | + # for rolling back) the transaction [Bug #747525]. | + # - Added PG_TIMETZ to the mix [Patch #708013]. | + # - Pg_Money will now accept a string as a parameter. | + # - PostgreSQL int2, int, int4 will now be cast into | + # Python ints. Int8 will be cast into a Python long. | + # Float4, float8, and money types will be cast into | + # a Python float. | # 07MAR2003 bga - Correct problem with the PgNumeric.__radd__ method. | # [Bug #694358] | *************** *** 447,452 **** BINARY = DBAPITypeObject('BINARY', PG_OID, PG_BLOB, PG_BYTEA) ! DATETIME = DBAPITypeObject('DATETIME', PG_DATE, PG_TIME, PG_TIMESTAMP, ! PG_TIMESTAMPTZ, PG_ABSTIME, PG_RELTIME, PG_INTERVAL, PG_TINTERVAL) --- 464,470 ---- BINARY = DBAPITypeObject('BINARY', PG_OID, PG_BLOB, PG_BYTEA) ! DATETIME = DBAPITypeObject('DATETIME', PG_DATE, PG_TIME, PG_TIMETZ, ! PG_TIMESTAMP, PG_TIMESTAMPTZ, ! PG_ABSTIME, PG_RELTIME, PG_INTERVAL, PG_TINTERVAL) *************** *** 492,496 **** def __repr__(self): ! return PQftypeName(self.value) def __str__(self): --- 510,514 ---- def __repr__(self): ! return repr(self.value) def __str__(self): *************** *** 547,551 **** # Convert any years using 365.2425 days per year, which is PostgreSQL's ! # 's assumption about the number of days in a year. if len(ydh) > 1: if ydh[1].lower().startswith('year'): --- 565,569 ---- # Convert any years using 365.2425 days per year, which is PostgreSQL's ! # assumption about the number of days in a year. if len(ydh) > 1: if ydh[1].lower().startswith('year'): *************** *** 738,742 **** return value else: ! return PgInt2(value) elif _ftv == PG_INT4: if type(value) is IntType: --- 756,760 ---- return value else: ! return int(value) elif _ftv == PG_INT4: if type(value) is IntType: *************** *** 751,755 **** if type(value) is PgInt8Type: return value ! return PgInt8(value) elif _ftv == PG_NUMERIC: if isinstance(value, PgNumeric): --- 769,773 ---- if type(value) is PgInt8Type: return value ! return long(value) elif _ftv == PG_NUMERIC: if isinstance(value, PgNumeric): *************** *** 769,773 **** return value else: ! return PgMoney(value) elif _ftv == DATETIME: if type(value) in [DateTimeType, DateTimeDeltaType]: --- 787,791 ---- return value else: ! return PgMoney(value).value elif _ftv == DATETIME: if type(value) in [DateTimeType, DateTimeDeltaType]: *************** *** 791,795 **** return value else: ! return PgOther(value) elif self.__conn.unicode_results \ and _ftv in (PG_CHAR, PG_BPCHAR, PG_TEXT, PG_VARCHAR, PG_NAME): --- 809,813 ---- return value else: ! return value elif self.__conn.unicode_results \ and _ftv in (PG_CHAR, PG_BPCHAR, PG_TEXT, PG_VARCHAR, PG_NAME): *************** *** 974,978 **** # NOTE: A PgOther object will use the PgQuoteString() function in libpq. ! def __quote__(self, forArray=0): if self.value: return PgQuoteString(self.value, forArray) --- 992,996 ---- # NOTE: A PgOther object will use the PgQuoteString() function in libpq. ! def _quote(self, forArray=0): if self.value: return PgQuoteString(self.value, forArray) *************** *** 1138,1142 **** # NOTE: A PgArray object will use the _handleArray() function to quote # itself. ! def __quote__(self, forArray=0): if self.value: return _handleArray(self.value) --- 1156,1160 ---- # NOTE: A PgArray object will use the _handleArray() function to quote # itself. ! def _quote(self, forArray=0): if self.value: return _handleArray(self.value) *************** *** 1244,1248 **** # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq ! def __quote__(self, forArray=0): if self.value: return PgQuoteBytea(self.value, forArray) --- 1262,1266 ---- # NOTE: A PgBytea object will use the PgQuoteBytea() function in libpq ! def _quote(self, forArray=0): if self.value: return PgQuoteBytea(self.value, forArray) *************** *** 1631,1635 **** return PgNumeric(-self.__v, self.__p, self.__s) ! def __quote__(self, forArray=0): if self.__v: if forArray: --- 1649,1653 ---- return PgNumeric(-self.__v, self.__p, self.__s) ! def _quote(self, forArray=0): if self.__v: if forArray: *************** *** 1678,1682 **** return ! self.value = float(value) if self.value < -21474836.48 or self.value > 21474836.47: raise OverflowError, 'money initialization' --- 1696,1709 ---- return ! if type(value) is StringType: ! if value[0] == '(': ! self.value = PgMoney(-float(replace(value[2:-1], ',', ''))) ! elif value[0] == '-': ! self.value = PgMoney(-float(replace(value[2:], ',', ''))) ! else: ! self.value = PgMoney(float(replace(value[1:], ',', ''))) ! else: ! self.value = float(value) ! if self.value < -21474836.48 or self.value > 21474836.47: raise OverflowError, 'money initialization' *************** *** 1777,1781 **** return '$%s' % _s ! def __quote__(self, forArray=0): if self.value: if forArray: --- 1804,1808 ---- return '$%s' % _s ! def _quote(self, forArray=0): if self.value: if forArray: *************** *** 1940,1944 **** return str(self.value) ! def __quote__(self, forArray=0): if self.value is not None: s = str(self.value) --- 1967,1971 ---- return str(self.value) ! def _quote(self, forArray=0): if self.value is not None: s = str(self.value) *************** *** 2185,2190 **** elif isinstance(_i, PgArray): _j = _j + _handleArray(_i)[1:-1] + ',' - elif hasattr(_i, '__quote__'): - _j = '%s%s,' % (_j, _i.__quote__(1)) elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) --- 2212,2215 ---- *************** *** 2212,2217 **** if value is None: return 'NULL' - elif hasattr(value, '__quote__'): - return value.__quote__() elif hasattr(value, '_quote'): return value._quote() --- 2237,2240 ---- *************** *** 2533,2536 **** --- 2556,2563 ---- "Creation of large object failed - Connection is not open." + if self.autocommit: + raise InterfaceError, \ + "Creation of large object failed - autocommit is on." + _nl = len(self.notices) _ct = 0 *************** *** 2554,2561 **** self.conn.query("ROLLBACK WORK") raise Warning, self.conn.notices.pop() - - if self.inTransaction: - if _ct: # Only commit the transaction if we started it. - self.conn.query("COMMIT WORK") return _lo --- 2581,2584 ---- |
From: Billy G. A. <bal...@us...> - 2003-06-17 01:36:45
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv6259 Modified Files: pglargeobject.c Log Message: 05JUN2003 bga Change the name of the quoting function back to _quote. __*__ type names should be restrict to system names. Index: pglargeobject.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pglargeobject.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** pglargeobject.c 3 Nov 2002 19:54:32 -0000 1.14 --- pglargeobject.c 17 Jun 2003 01:36:42 -0000 1.15 *************** *** 30,33 **** --- 30,35 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 05JUN2003 bga Change the name of the quoting function back to _quote. | + | __*__ type names should be restrict to system names. | | 02NOV2002 bga Change the name of the quoting function to __quote__. | | 19OCT2002 gh Made the 'closed' attribute of PgLargeObject an int | *************** *** 1274,1278 **** { "writelines", (PyCFunction)PgLo_writelines, 1, PgLo_writelines_Doc}, { "export", (PyCFunction)PgLo_export, 1, PgLo_export_Doc}, ! { "__quote__", (PyCFunction)PgLo_quote, 1}, { "_pickle", (PyCFunction)PgLo_pickle, 1}, { NULL, NULL } --- 1276,1280 ---- { "writelines", (PyCFunction)PgLo_writelines, 1, PgLo_writelines_Doc}, { "export", (PyCFunction)PgLo_export, 1, PgLo_export_Doc}, ! { "_quote", (PyCFunction)PgLo_quote, 1}, { "_pickle", (PyCFunction)PgLo_pickle, 1}, { NULL, NULL } |
From: Billy G. A. <bal...@us...> - 2003-06-17 01:35:47
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv6147 Modified Files: pgconnection.c Log Message: 15JUN2003 bga Applied patch by Laurent Pinchart to correct a problem with lo_import, lo_export, and lo_unlink. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** pgconnection.c 13 Dec 2002 11:30:11 -0000 1.17 --- pgconnection.c 17 Jun 2003 01:35:45 -0000 1.18 *************** *** 29,32 **** --- 29,34 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 15JUN2003 bga Applied patch by Laurent Pinchart to correct a problem | + | lo_import, lo_export, lo_unlink. | | 13DEC2002 gh In case PQgetResult returns NULL, let libPQgetResult | | return a Python None, like the docstring says. This is | *************** *** 961,965 **** return (PyObject *)NULL; ! if (!(oid = lo_import(PgConnection_Get(self), filename))) { PyErr_SetString(PqErr_OperationalError, "Can't import large object."); --- 963,967 ---- return (PyObject *)NULL; ! if ((oid = lo_import(PgConnection_Get(self), filename)) < 0) { PyErr_SetString(PqErr_OperationalError, "Can't import large object."); *************** *** 986,990 **** return (PyObject *)NULL; ! if (!(lo_export(PgConnection_Get(self), oid, filename))) { PyErr_SetString(PqErr_OperationalError, "Can't export large object."); --- 988,992 ---- return (PyObject *)NULL; ! if (lo_export(PgConnection_Get(self), oid, filename) < 0) { PyErr_SetString(PqErr_OperationalError, "Can't export large object."); *************** *** 1011,1015 **** return (PyObject *)NULL; ! if (lo_unlink(PgConnection_Get(self), oid)) { PyErr_SetString(PyExc_IOError, "error unlinking large object"); --- 1013,1017 ---- return (PyObject *)NULL; ! if (lo_unlink(PgConnection_Get(self), oid) < 0) { PyErr_SetString(PyExc_IOError, "error unlinking large object"); |
From: Billy G. A. <bal...@us...> - 2003-06-17 01:34:23
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv5867 Modified Files: pgboolean.c Log Message: 05JUN2003 bga Change the name of the quoting function back to _quote. __*__ type names should be restrict to system names. Index: pgboolean.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgboolean.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pgboolean.c 3 Nov 2002 19:54:32 -0000 1.11 --- pgboolean.c 17 Jun 2003 01:34:20 -0000 1.12 *************** *** 33,36 **** --- 33,38 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 05JUN2003 bga Change the name of the quoting function back to _quote. | + | __*__ type names should be restrict to system names. | | 02NOV2002 bga Change the name of the quoting function to __quote__. | | 26SEP2001 bga Change the constructors so that they return PyObject * | *************** *** 251,255 **** static PyMethodDef bool_methods[] = { ! { "__quote__", (PyCFunction)bool_quote, 1 }, { NULL, NULL } }; --- 253,257 ---- static PyMethodDef bool_methods[] = { ! { "_quote", (PyCFunction)bool_quote, 1 }, { NULL, NULL } }; |
From: Billy G. A. <bal...@us...> - 2003-06-17 01:28:33
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv5130 Modified Files: libpqmodule.c Log Message: 15JUN2003 bga Modified some comments to reflect reality. 02JUN2003 bga Added PG_TIMETZ to the mix [Patch #708013]. Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** libpqmodule.c 16 Jun 2003 11:59:41 -0000 1.28 --- libpqmodule.c 17 Jun 2003 01:28:30 -0000 1.29 *************** *** 39,42 **** --- 39,43 ---- | work. I just took the relevant DllMain function from | | the libpq sources and put it here. | + | 15JUN2003 bga Modified some comments to reflect reality. | | 09JUN2003 gh Applied patch from Laurent Pinchart: | | In libPQquoteString, bytea are quoted using as much as | *************** *** 44,47 **** --- 45,49 ---- | allocating (slen * 4) + 3 is not enough for data that | | contain lots of 0x00 bytes. | + | 02JUN2003 bga Added PG_TIMETZ to the mix [Patch #708013]. | | 28NOV2002 bga Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ | | and PG_REFCURSOR oids. [Bug #845360] | *************** *** 125,136 **** | 3. The single quote is quoted as \'. | | | ! | 4. The double quote is quoted as \". | | | ! | 5. All other characters are unchanged. | | | ! | Note: The double quote (") is escaped in case the quoted string is | ! | part of a PostgreSQL array, which uses double quotes around | ! | string values instead of single quotes. It saves having to do | ! | a global search and replace of double quotes in Python. | \***********************************************************************/ --- 127,150 ---- | 3. The single quote is quoted as \'. | | | ! | 4. All other characters are unchanged. | | | ! | Note: If the optional forArray argument is 1, then the escaping is | ! | changed as follows: | ! | 1. Control characters are quoted as follows: | | | ! | Value Quoted Representation | ! | ----- --------------------- | ! | NUL * NOT ALLOWED * | ! | BS \\b | ! | TAB \\t | ! | NL \\n | ! | CR \\r | ! | other \OOO where OOO is the octal representation of | ! | the control character's ordinal number. | ! | | ! | 2. The backslash is escpaed as \\\\. | ! | 3. The single quote is escaped as \'. | ! | 4. The double quote is escaped as \\". | ! | 5. All other characters are unchanged. | \***********************************************************************/ *************** *** 707,710 **** --- 721,725 ---- case PG_TID: desc = "tid"; break; case PG_TIME: desc = "time"; break; + case PG_TIMETZ: desc = "timetz"; break; case PG_TIMESTAMP: desc = "timestamp"; break; case PG_TIMESTAMPTZ: desc = "timestamptz"; break; *************** *** 1087,1090 **** --- 1102,1106 ---- PyDict_SetItemString(d, "PG_TID", Py_BuildValue("i", PG_TID)); PyDict_SetItemString(d, "PG_TIME", Py_BuildValue("i", PG_TIME)); + PyDict_SetItemString(d, "PG_TIMETZ", Py_BuildValue("i", PG_TIMETZ)); PyDict_SetItemString(d, "PG_TIMESTAMP", Py_BuildValue("i", PG_TIMESTAMP)); PyDict_SetItemString(d, "PG_TIMESTAMPTZ", Py_BuildValue("i", PG_TIMESTAMPTZ)); |
From: Gerhard H?r. <gha...@us...> - 2003-06-16 13:49:11
|
Update of /cvsroot/pypgsql/pypgsql/port In directory sc8-pr-cvs1:/tmp/cvs-serv21944/port Modified Files: port.h Log Message: 16JUN2003 gh The Python developers chose to replace LONG_LONG with PY_LONG_LONG under Python 2.3. We'll continue to use LONG_LONG for now. This patch ensures pyPgSQL can still be compiled under Python 2.3. Index: port.h =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/port/port.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** port.h 2 Oct 2002 03:55:24 -0000 1.2 --- port.h 16 Jun 2003 13:49:07 -0000 1.3 *************** *** 30,33 **** --- 30,39 ---- #endif + /* Under Python 2.3, LONG_LONG has been replaced by PY_LONG_LONG. We continue + * using LONG_LONG, even under 2.3 or later */ + #ifdef PY_LONG_LONG + #define LONG_LONG PY_LONG_LONG + #endif + /******************************************************* * Prototypes for the string functions that we include * |
From: Gerhard H?r. <gha...@us...> - 2003-06-16 11:59:44
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv8569 Modified Files: libpqmodule.c libpqmodule.h Log Message: 16JUN2003 gh On win32, we usually statically link against libpq. Because of fortunate circumstances, a problem didn't show up until now: we need to call WSAStartup() to initialize the socket stuff from Windows *in our module* in order for the statically linked libpq to work. I just took the relevant DllMain function from the libpq sources and put it here. Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** libpqmodule.c 9 Jun 2003 14:56:58 -0000 1.27 --- libpqmodule.c 16 Jun 2003 11:59:41 -0000 1.28 *************** *** 32,35 **** --- 32,42 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 16JUN2003 gh On win32, we usually statically link against libpq. | + | Because of fortunate circumstances, a problem didn't | + | show up until now: we need to call WSAStartup() to | + | initialize the socket stuff from Windows *in our | + | module* in order for the statically linked libpq to | + | work. I just took the relevant DllMain function from | + | the libpq sources and put it here. | | 09JUN2003 gh Applied patch from Laurent Pinchart: | | In libPQquoteString, bytea are quoted using as much as | *************** *** 947,950 **** --- 954,985 ---- { NULL, NULL } }; + + #ifdef MS_WIN32 + BOOL WINAPI + DllMain(HINSTANCE hinstDLL, DWORD fdwReason, + LPVOID lpReserved) + { + WSADATA wsaData; + + switch (fdwReason) + { + case DLL_PROCESS_ATTACH: + if (WSAStartup(MAKEWORD(1, 1), &wsaData)) + { + /* + * No really good way to do error handling here, since we + * don't know how we were loaded + */ + return FALSE; + } + break; + case DLL_PROCESS_DETACH: + WSACleanup(); + break; + } + + return TRUE; + } + #endif DL_EXPORT(void) initlibpq(void) Index: libpqmodule.h =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** libpqmodule.h 2 Oct 2002 04:06:32 -0000 1.9 --- libpqmodule.h 16 Jun 2003 11:59:41 -0000 1.10 *************** *** 40,43 **** --- 40,50 ---- #include "pgversion.h" + #ifdef MS_WIN32 + #define WIN32_LEAN_AND_MEAN + #include <winsock.h> + #include <windows.h> + #include "win32.h" + #endif + #define MODULE_NAME "libpq" |
From: Gerhard H?r. <gha...@us...> - 2003-06-09 14:57:02
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv26536 Modified Files: libpqmodule.c Log Message: 09JUN2003 gh Applied patch from Laurent Pinchart: In libPQquoteString, bytea are quoted using as much as 5 bytes per input byte (0x00 is quoted '\\000'), so allocating (slen * 4) + 3 is not enough for data that contain lots of 0x00 bytes. Index: libpqmodule.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/libpqmodule.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** libpqmodule.c 1 Dec 2002 04:59:24 -0000 1.26 --- libpqmodule.c 9 Jun 2003 14:56:58 -0000 1.27 *************** *** 32,35 **** --- 32,40 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 09JUN2003 gh Applied patch from Laurent Pinchart: | + | In libPQquoteString, bytea are quoted using as much as | + | 5 bytes per input byte (0x00 is quoted '\\000'), so | + | allocating (slen * 4) + 3 is not enough for data that | + | contain lots of 0x00 bytes. | | 28NOV2002 bga Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ | | and PG_REFCURSOR oids. [Bug #845360] | *************** *** 264,268 **** /* Calculate the size for the new memory string. */ ! i = (slen * (forArray ? 8 : 4)) + 3; sout = (unsigned char *)PyMem_Malloc(i); /* Assume every char is quoted */ --- 269,273 ---- /* Calculate the size for the new memory string. */ ! i = (slen * (forArray ? 8 : 5)) + 3; sout = (unsigned char *)PyMem_Malloc(i); /* Assume every char is quoted */ |
From: Billy G. A. <bal...@us...> - 2003-05-29 01:39:24
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv15391 Modified Files: pgnotify.c Log Message: 28MAY2002 bga Fixed a bug in the code. The code in question use to work, but doesn't anymore (possible change to libpq?). Index: pgnotify.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgnotify.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pgnotify.c 6 Sep 2001 04:42:21 -0000 1.6 --- pgnotify.c 29 May 2003 01:39:21 -0000 1.7 *************** *** 30,33 **** --- 30,35 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 28MAY2002 bga Fixed a bug in the code. The code in question use to | + | work, but doesn't anymore (possible change to libpq?). | | 06SEP2001 bga Clarified an embedded assignment within an if test. | | 30AUG2001 bga Use PyObject_Del() instead of PyMem_Free() in dealloc() | *************** *** 64,68 **** (PgNotify *)NULL) { ! self->relname = Py_BuildValue("s", &(note->relname)); self->be_pid = Py_BuildValue("i", note->be_pid); free(note); --- 66,70 ---- (PgNotify *)NULL) { ! self->relname = Py_BuildValue("s", note->relname); self->be_pid = Py_BuildValue("i", note->be_pid); free(note); |
From: Gerhard H?r. <gha...@us...> - 2003-04-25 00:34:08
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv12183 Modified Files: setup.py Log Message: 25APR2003 gh Added changes for registration with the Python Package index (PyPI) (http://python.org/pypi). Index: setup.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/setup.py,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** setup.py 1 Dec 2002 16:14:11 -0000 1.20 --- setup.py 25 Apr 2003 00:34:03 -0000 1.21 *************** *** 45,48 **** --- 45,50 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 25APR2003 gh Added changes for registration with the Python Package | + # index (PyPI) (http://python.org/pypi). | # 01DEC2002 gh Simplified build process and got rid of setup.config. | # setup.config prevented the bdist_rpm command of dist- | *************** *** 151,154 **** --- 153,174 ---- library_dirs = ["/usr/local/lib"] + # patch distutils if it can't cope with the "classifiers" keyword + if sys.version < '2.2.3': + from distutils.dist import DistributionMetadata + DistributionMetadata.classifiers = None + DistributionMetadata.download_url = None + + classifiers = [ + "Development Status :: 5 - Production/Stable", + "Environment :: Other Environment", + "Intended Audience :: Developers", + "License :: OSI Approved :: Python License (CNRI Python License)", + "Natural Language :: English", + "Operating System :: Microsoft :: Windows :: Windows 95/98/2000", + "Operating System :: POSIX", + "Programming Language :: C", + "Programming Language :: Python", + "Topic :: Database :: Front-Ends"] + setup ( name = "pyPgSQL", *************** *** 168,172 **** runtime_library_dirs = pypgsql_rt_dirs, libraries = optional_libs ! )] ) --- 188,193 ---- runtime_library_dirs = pypgsql_rt_dirs, libraries = optional_libs ! )], ! classifiers = classifiers ) |
From: Billy G. A. <bal...@us...> - 2003-03-07 06:24:43
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv10990 Modified Files: PgSQL.py Log Message: 07MAR2003 bga - Correct problem in the PgNumeric.__radd__ method. [Bug #694358] - Correct problem with conversion of negitive integers (with a given scale and precision) to PgNumerics. [Bug #694358] - Work around a problem where the precision and scale of a query result can be different from the first result in the result set. [Bug #697221] Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** PgSQL.py 12 Jan 2003 10:03:04 -0000 1.31 --- PgSQL.py 7 Mar 2003 06:24:39 -0000 1.32 *************** *** 30,33 **** --- 30,42 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 07MAR2003 bga - Correct problem with the PgNumeric.__radd__ method. | + # [Bug #694358] | + # - Correct problem with conversion of negitive integers | + # (with a given scale and precision) to PgNumerics. | + # [Bug #694358] | + # - Work around a problem where the precision and scale | + # of a query result can be different from the first re- | + # sult in the result set. | + # [Bug #697221] | # 12JAN2003 bga - Change the code so that the display length in the | # cursor.description attribute is always None instead | *************** *** 747,751 **** return value else: ! return PgNumeric(value, _p, _s) elif _ftv == PG_MONEY: if isinstance(value, PgMoney): --- 756,768 ---- return value else: ! try: ! return PgNumeric(value, _p, _s) ! except OverflowError: ! # If we reached this point, then the precision and scale ! # of the current field does not match the precision and ! # scale of the first record in the result set (there are ! # a few reasons that this can happen). Let PgNumeric ! # figure out a precision and scale from the value. ! return PgNumeric(value) elif _ftv == PG_MONEY: if isinstance(value, PgMoney): *************** *** 1256,1260 **** # Check to see if the value is too large for the given # precision/scale ! _v = str(value) if _v[-1:] == 'L': _v = _v[:-1] --- 1273,1277 ---- # Check to see if the value is too large for the given # precision/scale ! _v = str(abs(value)) if _v[-1:] == 'L': _v = _v[:-1] *************** *** 1270,1274 **** # First get the value as a (trimmed) string if type(value) is FloatType: ! _v = repr(value) else: _v = value.split() --- 1287,1291 ---- # First get the value as a (trimmed) string if type(value) is FloatType: ! _v = str(value) else: _v = value.split() *************** *** 1493,1497 **** def __radd__(self, other): ! return __add__(self, other) def __iadd__(self, other): --- 1510,1514 ---- def __radd__(self, other): ! return self.__add__(other) def __iadd__(self, other): *************** *** 1525,1529 **** def __rsub__(self, other): ! return self.__sub__(other, self) def __isub__(self, other): --- 1542,1546 ---- def __rsub__(self, other): ! return other.__sub__(self) def __isub__(self, other): *************** *** 1569,1573 **** def __rdiv__(self, other): ! return self.__div__(other, self) def __idiv__(self, other): --- 1586,1590 ---- def __rdiv__(self, other): ! return other.__div__(self) def __idiv__(self, other): |
From: Billy G. A. <bal...@us...> - 2003-01-12 10:03:10
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv8209/pyPgSQL Modified Files: PgSQL.py Log Message: 12JAN2003 bga - Change the code so that the display length in the cursor.description attribute is always None instead of '-1'. - Fixed another problem with interval <-> DateTimeDelta casting. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** PgSQL.py 23 Dec 2002 05:45:43 -0000 1.30 --- PgSQL.py 12 Jan 2003 10:03:04 -0000 1.31 *************** *** 30,33 **** --- 30,38 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 12JAN2003 bga - Change the code so that the display length in the | + # cursor.description attribute is always None instead | + # of '-1'. | + # - Fixed another problem with interval <-> DateTimeDelta | + # casting. | # 23DEC2002 bga - Corrected a problem that caused the close of a portal | # (ie. PostgreSQL cursor) to fail. | *************** *** 534,548 **** # Convert any years using 365.2425 days per year, which is PostgreSQL's # 's assumption about the number of days in a year. ! if ydh[1].lower().startswith('year'): ! result += parser('%s days' % ((int(ydh[0]) * 365.2425),)) ! ydh = ydh[2:] # Converts any days and adds it to the years (as an interval) ! if ydh[1].lower().startswith('day'): ! result += parser('%s days' % (ydh[0],)) ! ydh = ydh[2:] # Adds in the hours, minutes, seconds (as an interval) ! result += parser(ydh[0]) return result --- 539,556 ---- # Convert any years using 365.2425 days per year, which is PostgreSQL's # 's assumption about the number of days in a year. ! if len(ydh) > 1: ! if ydh[1].lower().startswith('year'): ! result += parser('%s days' % ((int(ydh[0]) * 365.2425),)) ! ydh = ydh[2:] # Converts any days and adds it to the years (as an interval) ! if len(ydh) > 1: ! if ydh[1].lower().startswith('day'): ! result += parser('%s days' % (ydh[0],)) ! ydh = ydh[2:] # Adds in the hours, minutes, seconds (as an interval) ! if len(ydh) > 0: ! result += parser(ydh[0]) return result *************** *** 2802,2806 **** _p = (_s >> 16) & 0xffff _s = _s & 0xffff ! _j.append(_p + 3) # Display size _j.append(_p) # Internal (storage) size _j.append(_p) # Precision --- 2810,2814 ---- _p = (_s >> 16) & 0xffff _s = _s & 0xffff ! _j.append(None) # Display size (always None since PG7.3) _j.append(_p) # Internal (storage) size _j.append(_p) # Precision *************** *** 2811,2815 **** if _pl == -1: _pl = _mod - self._varhdrsz ! _j.append(_pl) # Display size _s = _res.fsize(_i) if _s == -1: --- 2819,2823 ---- if _pl == -1: _pl = _mod - self._varhdrsz ! _j.append(None) # Display size (always None since PG7.3) _s = _res.fsize(_i) if _s == -1: *************** *** 2817,2821 **** _j.append(_s) # Internal (storage) size if _typ.value == PG_MONEY: ! _j.append(9) # Presicion and Scale (from _j.append(2) # the PostgreSQL doco.) else: --- 2825,2829 ---- _j.append(_s) # Internal (storage) size if _typ.value == PG_MONEY: ! _j.append(9) # Presicion and Scale (from _j.append(2) # the PostgreSQL doco.) else: |
From: Billy G. A. <bal...@us...> - 2002-12-23 05:45:46
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv9576/pyPgSQL Modified Files: PgSQL.py Log Message: 23DEC2002 bga - Corrected a problem that caused the close of a portal (ie. PostgreSQL cursor) to fail. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** PgSQL.py 14 Dec 2002 05:13:34 -0000 1.29 --- PgSQL.py 23 Dec 2002 05:45:43 -0000 1.30 *************** *** 30,33 **** --- 30,35 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 23DEC2002 bga - Corrected a problem that caused the close of a portal | + # (ie. PostgreSQL cursor) to fail. | # 13DEC2002 bga - Corrected a problem with interval <-> DateTimeDelta | # casting. [Bug #653044] | *************** *** 2639,2643 **** if (self.closed == 0) and self.conn.inTransaction: try: ! self.conn.conn.query("CLOSE %s" % self.name) except: pass --- 2641,2645 ---- if (self.closed == 0) and self.conn.inTransaction: try: ! self.conn.conn.query('CLOSE "%s"' % self.name) except: pass |
From: Billy G. A. <bal...@us...> - 2002-12-14 05:13:38
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv14457/pyPgSQL Modified Files: PgSQL.py Log Message: 13DEC2002 bga - Corrected a problem with interval <-> DateTimeDelta casting. [Bug #653044] Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PgSQL.py 6 Dec 2002 05:20:12 -0000 1.28 --- PgSQL.py 14 Dec 2002 05:13:34 -0000 1.29 *************** *** 30,33 **** --- 30,35 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 13DEC2002 bga - Corrected a problem with interval <-> DateTimeDelta | + # casting. [Bug #653044] | # 06DEC2002 bga - Corrected problem found by Adam Buraczewski in the | # __setupTransaction function. | *************** *** 385,394 **** TimestampFromTicks = DateTime.TimestampFromTicks #-------------------------------+ ! # And also the DateTime types | #-------------------------------+ DateTimeType = DateTime.DateTimeType DateTimeDeltaType = DateTime.DateTimeDeltaType #-----------------------------------------------------------------------+ --- 387,403 ---- TimestampFromTicks = DateTime.TimestampFromTicks + #-----------------------------------------------+ + # The DateTimeDelta type for PgInterval support | + #-----------------------------------------------+ + + DateTimeDelta = DateTime.DateTimeDelta + #-------------------------------+ ! # Also the DateTime types | #-------------------------------+ DateTimeType = DateTime.DateTimeType DateTimeDeltaType = DateTime.DateTimeDeltaType + DateTimeDelta = DateTime.DateTimeDelta #-----------------------------------------------------------------------+ *************** *** 511,526 **** self.__conn = None ! def interval2datetimedelta(self, s): ! """Parses both 7.0.x and 7.1.x styles of PostgreSQL INTERVALs""" ! if s.startswith("-"): ! factor = -1 ! else: ! factor = 1 ! s = s.replace('days ', '').replace("-", "") ! l = s.split() ! if len(l) != 2: ! l = ['0'] + l ! return factor * (DateTime.DateTimeDelta(int(l[0])) \ ! + DateTime.DateTimeDeltaFrom(l[1])) def parseArray(self, s): --- 520,548 ---- self.__conn = None ! def interval2DateTimeDelta(self, s): ! """Parses PostgreSQL INTERVALs. ! The expected format is [[[-]YY years] [-]DD days] [-]HH:MM:SS.ss""" ! parser = DateTime.Parser.DateTimeDeltaFromString ! ! ydh = s.split() ! ago = 1 ! ! result = DateTimeDelta(0) ! ! # Convert any years using 365.2425 days per year, which is PostgreSQL's ! # 's assumption about the number of days in a year. ! if ydh[1].lower().startswith('year'): ! result += parser('%s days' % ((int(ydh[0]) * 365.2425),)) ! ydh = ydh[2:] ! ! # Converts any days and adds it to the years (as an interval) ! if ydh[1].lower().startswith('day'): ! result += parser('%s days' % (ydh[0],)) ! ydh = ydh[2:] ! ! # Adds in the hours, minutes, seconds (as an interval) ! result += parser(ydh[0]) ! ! return result def parseArray(self, s): *************** *** 726,730 **** else: if _ftv == PG_INTERVAL: ! return self.interval2datetimedelta(value) else: return DateTime.ISO.ParseAny(value) --- 748,752 ---- else: if _ftv == PG_INTERVAL: ! return self.interval2DateTimeDelta(value) else: return DateTime.ISO.ParseAny(value) *************** *** 2066,2069 **** --- 2088,2093 ---- # _quoteall() -- transforms all elements of a list or diction- | # ary using _quote. | + # dateTimeDelta2Interval() -- converts a DateTimeDelta type into | + # a string PostgreSQL accepts as a interval. | #-----------------------------------------------------------------------+ *************** *** 2138,2143 **** elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) ! elif type(_i) in [DateTime.DateTimeType, DateTime.DateTimeDeltaType]: _j = '%s"%s",' % (_j, _i) elif type(_i) is PgInt2Type or isinstance(_i, PgInt8Type): _j = '%s%s,' % (_j, str(_i)) --- 2162,2169 ---- elif hasattr(_i, '_quote'): _j = '%s%s,' % (_j, _i._quote(1)) ! elif type(_i) is DateTimeType: _j = '%s"%s",' % (_j, _i) + elif type(_i) is DateTime.DateTimeDeltaType: + _j = '%s"%s",' % (_j, dateTimeDelta2Interval(_i)) elif type(_i) is PgInt2Type or isinstance(_i, PgInt8Type): _j = '%s%s,' % (_j, str(_i)) *************** *** 2163,2168 **** elif hasattr(value, '_quote'): return value._quote() ! elif type(value) in [DateTimeType, DateTimeDeltaType]: return "'%s'" % value elif type(value) is StringType: return PgQuoteString(value) --- 2189,2196 ---- elif hasattr(value, '_quote'): return value._quote() ! elif type(value) is DateTimeType: return "'%s'" % value + elif type(value) is DateTimeDeltaType: + return "'%s'" % dateTimeDelta2Interval(value) elif type(value) is StringType: return PgQuoteString(value) *************** *** 2193,2196 **** --- 2221,2247 ---- return t + + def dateTimeDelta2Interval(interval): + """ + DateTimeDelta2Interval - Converts a DateTimeDelta to an interval string\n + The input format is [+-]DD:HH:MM:SS.ss\n + The output format is DD days HH:MM:SS.ss [ago]\n + """ + + if type(interval) is DateTimeDeltaType: + s = str(interval) + ago = '' + if s[0] == '-': + ago = ' ago' + s = s[1:] + else: + ago = '' + s = s.split(':') + if len(s) < 4: + return '%s:%s:%s %s' % (s[0], s[1], s[2], ago) + + return '%s days %s:%s:%s %s' % (s[0], s[1], s[2], s[3], ago) + else: + raise TypeException, "DateTimeDelta2Interval requires a DataTimeDelta." #-----------------------------------------------------------------------+ |
From: Gerhard H?r. <gha...@us...> - 2002-12-13 11:30:14
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv23826 Modified Files: pgconnection.c Log Message: 13DEC2002 gh In case PQgetResult returns NULL, let libPQgetResult return a Python None, like the docstring says. This is necessary in order to be able to cancel queries, as after cancelling a query with PQrequestCancel, we need to read results until PQgetResult returns NULL. Index: pgconnection.c =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pgconnection.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** pgconnection.c 3 Nov 2001 19:02:53 -0000 1.16 --- pgconnection.c 13 Dec 2002 11:30:11 -0000 1.17 *************** *** 29,32 **** --- 29,37 ---- | Date Ini Description | | --------- --- ------------------------------------------------------- | + | 13DEC2002 gh In case PQgetResult returns NULL, let libPQgetResult | + | return a Python None, like the docstring says. This is | + | necessary in order to be able to cancel queries, as | + | after cancelling a query with PQrequestCancel, we need | + | to read results until PQgetResult returns NULL. | | 03NOV2001 bga Fixed a possible memory leak. | | 17OCT2001 bga Added the lo_export() method. It was overlooked in the | *************** *** 400,403 **** --- 405,414 ---- res = PQgetResult(PgConnection_Get(self)); + + if (res == NULL) + { + Py_INCREF(Py_None); + return Py_None; + } if ((rtype = getResultType(res)) == RESULT_ERROR) |
From: Gerhard H?r. <gha...@us...> - 2002-12-09 13:45:56
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv21122 Modified Files: TODO Log Message: 09DEC2002 gh Updated TODO by deleting items that are already done. Index: TODO =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/TODO,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TODO 2 Oct 2002 11:49:10 -0000 1.4 --- TODO 9 Dec 2002 13:45:53 -0000 1.5 *************** *** 6,20 **** ========== ! * Unicode support - Add automatic encoding conversion to the last patch on ! Sourceforge. (gh) ! ! * transparent use of refcursors returned from execute/callproc. This will ! require the addition of a type that reflects PostgreSQL cursor objects (in ! contrast to Python DB-API cursor objects). This object will be very similar ! to Python DB-API cursor objects, but not have any execute or callproc methods ! ! * a PgArray type for PostgreSQL ARRAYs. lists and tuples are no longer ! converted to PostgreSQL ARRAYs, but are instead quoted for insertion into the ! SQL IN function * support for all standard PostgreSQL data types (point, line, box, etc.) --- 6,10 ---- ========== ! * Unicode support - Evaluate adding automatic encoding conversion. (gh) * support for all standard PostgreSQL data types (point, line, box, etc.) *************** *** 63,67 **** ============= ! * user's guide, using Docbook/XML, adapting from Redhat Database Documentation (I've got the ok from its author) --- 53,57 ---- ============= ! * user's guide, using OpenOffice, adapting from Redhat Database Documentation (I've got the ok from its author) |
From: Billy G. A. <bal...@us...> - 2002-12-06 05:29:41
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv5233 Modified Files: Announce ChangeLog Log Message: 06DEC2002 bga - Updated files with descriptions of some last minute changes. Index: Announce =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/Announce,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Announce 1 Dec 2002 20:16:51 -0000 1.21 --- Announce 6 Dec 2002 05:29:37 -0000 1.22 *************** *** 120,124 **** Changes to README ----------------- ! * Updates for 2.3rc1. * Converted the whole document into reStructuredText, so we can easily built a HTML version using docutils (http://docutils.sf.net/). --- 120,124 ---- Changes to README ----------------- ! * Updates for 2.3. * Converted the whole document into reStructuredText, so we can easily built a HTML version using docutils (http://docutils.sf.net/). *************** *** 131,134 **** --- 131,146 ---- Changes to PgSQL.py ------------------- + * Fixed various problems with the PgNumeric constructor and formatting + routines. + * Fixed problems with new __setupTransaction function: | + 1. Made it a method of Connection, not Cursor. + 2. inTransaction was only set if TransactionLevel was set. + * Fixed instances where method name was incorrect: + Connection__gcCursor -> _Connection__gcCursor + Connection__closeCursor -> _Connection__closeCursor + * Cleaned up code where there was unneeded references to conn in Connection + class. | + * Handle the new '__quote__' method for arrays, too. + * Still handle '_quote' methods for backwards compatibility. * Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ and PG_REFCURSOR oids. * Reference cursors are now type-casted into cursor objects. Index: ChangeLog =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/ChangeLog,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** ChangeLog 1 Dec 2002 18:30:23 -0000 1.18 --- ChangeLog 6 Dec 2002 05:29:37 -0000 1.19 *************** *** 37,40 **** --- 37,52 ---- Changes to PgSQL.py ------------------- + * Fixed various problems with the PgNumeric constructor and formatting + routines. + * Fixed problems with new __setupTransaction function: | + 1. Made it a method of Connection, not Cursor. + 2. inTransaction was only set if TransactionLevel was set. + * Fixed instances where method name was incorrect: + Connection__gcCursor -> _Connection__gcCursor + Connection__closeCursor -> _Connection__closeCursor + * Cleaned up code where there was unneeded references to conn in Connection + class. | + * Handle the new '__quote__' method for arrays, too. + * Still handle '_quote' methods for backwards compatibility. * Fixed changed PG_TIMESTAMP oid, added PG_TIMESTAMPTZ and PG_REFCURSOR oids. * Reference cursors are now type-casted into cursor objects. |
From: Billy G. A. <bal...@us...> - 2002-12-06 05:20:17
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv2996/pyPgSQL Modified Files: PgSQL.py Log Message: 06DEC2002 bga - Corrected problem found by Adam Buraczewski in the __setupTransaction function. - Allow both 'e' and 'E' to signify an exponet in the PgNumeric constructor. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** PgSQL.py 5 Dec 2002 04:22:02 -0000 1.27 --- PgSQL.py 6 Dec 2002 05:20:12 -0000 1.28 *************** *** 30,33 **** --- 30,37 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 06DEC2002 bga - Corrected problem found by Adam Buraczewski in the | + # __setupTransaction function. | + # - Allow both 'e' and 'E' to signify an exponet in the | + # PgNumeric constructor. | # 04DEC2002 bga - Correct some problems that were missed in yesterday's | # fixes (Thanks, Adam, for the help with the problems) | *************** *** 1254,1258 **** # Ensure that _e and _v contains a sane value if _e < 0: ! _e = len(_v) if _d < 0: --- 1258,1264 ---- # Ensure that _e and _v contains a sane value if _e < 0: ! _e = _v.rfind('E') ! if _e < 0: ! _e = len(_v) if _d < 0: *************** *** 2350,2353 **** --- 2356,2360 ---- self.conn.query("BEGIN WORK") if self.TransactionLevel != "": + _nl = len(self.notices) self.conn.query('SET TRANSACTION ISOLATION LEVEL %s' % self.TransactionLevel) |
From: Billy G. A. <bal...@us...> - 2002-12-05 05:42:45
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv1992 Modified Files: MANIFEST MANIFEST.in Log Message: 04DEC2002 bga Updated MANIFEST (and MANIFEST.in) to include README.html and README.win32. Index: MANIFEST =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/MANIFEST,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** MANIFEST 1 Dec 2002 22:20:12 -0000 1.10 --- MANIFEST 5 Dec 2002 05:42:42 -0000 1.11 *************** *** 2,5 **** --- 2,7 ---- ChangeLog README + README.html + README.win32 libpqmodule.c libpqmodule.h Index: MANIFEST.in =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/MANIFEST.in,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** MANIFEST.in 16 Sep 2002 05:43:04 -0000 1.4 --- MANIFEST.in 5 Dec 2002 05:42:42 -0000 1.5 *************** *** 1,3 **** ! include *.c *.h Announce ChangeLog recursive-include examples *.py recursive-include test *.py --- 1,3 ---- ! include *.c *.h Announce ChangeLog README.* recursive-include examples *.py recursive-include test *.py |
From: Billy G. A. <bal...@us...> - 2002-12-05 05:34:33
|
Update of /cvsroot/pypgsql/pypgsql In directory sc8-pr-cvs1:/tmp/cvs-serv32076 Modified Files: README Added Files: README.html Log Message: 04DEC2002 bga Updated readme file to generate the README.html using docutils-0.2 on my system. --- Added the generated README.html to the repository. --- NEW FILE: README.html --- <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="generator" content="Docutils: http://docutils.sourceforge.net/"> <link rel="stylesheet" href="default.css" type="text/css" /> <meta name="version" content="#ident "@(#) $Id: README.html,v 1.1 2002/12/05 05:34:30 ballie01 Exp $"" /> </head> <body> <div class="document"> <table class="docinfo" frame="void" rules="none"> <col class="docinfo-name" /> <col class="docinfo-content" /> <tbody valign="top"> <tr><td class="docinfo-name">Version: </td><td> #ident "@(#) $Id: README.html,v 1.1 2002/12/05 05:34:30 ballie01 Exp $"</td></tr> </tbody> </table> [...1867 lines suppressed...] [<pyPgSQL.PgSQL.Cursor instance at 0x818495c>] >>> c = rs[0] >>> for i in c.description: ... print i ... ['model_year', varchar, 4, 8, None, None, None, 0] ['mktg_div_name', varchar, 50, 54, None, None, None, 0] ['model_desc', varchar, 50, 54, None, None, None, 0] ['book_types', varchar, 50, 54, None, None, None, 0] ['vehicle_syskey', integer, 4, 4, None, None, None, 0] >>> r = c.fetchone() >>> r ['2003', 'Buick', 'Century', '1;8;9', 2211] >>> </pre> </blockquote> </div> </div> </div> </body> </html> Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** README 1 Dec 2002 20:11:07 -0000 1.29 --- README 5 Dec 2002 05:34:30 -0000 1.30 *************** *** 1,7 **** :Version: #ident "@(#) $Id$" pyPgSQL - v2.3: Python DB-API 2.0 Compliant Interface Module for PostgreSQL. ! ============================================================================ ! 0. Copyright notice and License =============================== --- 1,8 ---- :Version: #ident "@(#) $Id$" + ---------------------------------------------------------------------------- pyPgSQL - v2.3: Python DB-API 2.0 Compliant Interface Module for PostgreSQL. ! ---------------------------------------------------------------------------- ! =============================== 0. Copyright notice and License =============================== *************** *** 28,31 **** --- 29,33 ---- PERFORMANCE OF THIS SOFTWARE. + ================= 1. About pyPgSQL ================= *************** *** 83,88 **** :pgversion.[ch]: the C code implementing the PgVersion class. ! :pymemstrdup.c: the C code implementing a version of strdup() that ! uses Python's heap for the needed memory. :pyPgSQL/__init__.py: the initialization code for the pyPgSQL package. --- 85,90 ---- :pgversion.[ch]: the C code implementing the PgVersion class. ! :pymemstrdup.c: the C code implementing a version of strdup() ! that uses Python's heap for the needed memory. :pyPgSQL/__init__.py: the initialization code for the pyPgSQL package. *************** *** 113,117 **** b. Edit the setup.py file to reflect the your environment. The setup.py file ! contains comments regarding USE_CUSTOM to guide you in customizing this file. c. Execute ``python setup.py build`` to build the extension module. --- 115,120 ---- b. Edit the setup.py file to reflect the your environment. The setup.py file ! contains comments regarding USE_CUSTOM to guide you in customizing this ! file. c. Execute ``python setup.py build`` to build the extension module. *************** *** 122,127 **** automatically detected.) ! Note: You may require root access to install the module. Consult your ! local system administrator. 1.4 Testing the PgSQL module. --- 125,130 ---- automatically detected.) ! :NOTE: You may require root access to install the module. ! Consult your local system administrator. 1.4 Testing the PgSQL module. *************** *** 131,135 **** directory: ! ``python test/PgSQLTestCases.py`` If the test cases run without any failures, then you can be reasonably sure --- 134,138 ---- directory: ! ``python test/PgSQLTestCases.py`` If the test cases run without any failures, then you can be reasonably sure *************** *** 141,146 **** such a database with the following commands:: ! createdb -E UNICODE pypgsql ! createlang plpgsql pypgsql 1.5 Additional information about ... --- 144,149 ---- such a database with the following commands:: ! createdb -E UNICODE pypgsql ! createlang plpgsql pypgsql 1.5 Additional information about ... *************** *** 153,156 **** --- 156,160 ---- :mxDateTime: http://starship.python.net/~lemburg/mxDateTime.html + =========================== 2. Programming Information =========================== *************** *** 158,172 **** 2.1 The libpq module -------------------- ! 2.1.1 Importing libpq --------------------- The module, libpq, is part of the pyPgSQL package. It is imported using ! the following statement:: ! from pyPgSQL import libpq - Note: This has change from 1.x releases of pyPgSQL where "import libpq" - was used to import the module. 2.1.2 libpq Constants --- 162,174 ---- 2.1 The libpq module -------------------- ! 2.1.1 Importing libpq --------------------- The module, libpq, is part of the pyPgSQL package. It is imported using ! the following statement: ! >>> from pyPgSQL import libpq 2.1.2 libpq Constants *************** *** 234,238 **** :RESULT_DQL: result was generated by a DQL query. :RESULT_DML: result was generated by a DML query. ! :RESULT_EMPTY: query generated an empty result.. :RESULT_ERROR: query generated an error. --- 236,240 ---- :RESULT_DQL: result was generated by a DQL query. :RESULT_DML: result was generated by a DML query. ! :RESULT_EMPTY: query generated an empty result. :RESULT_ERROR: query generated an error. *************** *** 368,375 **** *Description*: This method returns a PgBoolean object initialized from the ! value of object. It recognizes the following string values:: ! For true.: '1', 'T', 'TRUE', 'Y', 'YES', 'ON' ! For false: '0', 'F', 'FALSE', 'N', 'NO', 'OFF' For numeric object, zero is false, non-zero is true. --- 370,377 ---- *Description*: This method returns a PgBoolean object initialized from the ! value of object. It recognizes the following string values: ! For true.: '1', 'T', 'TRUE', 'Y', 'YES', 'ON' ! For false: '0', 'F', 'FALSE', 'N', 'NO', 'OFF' For numeric object, zero is false, non-zero is true. *************** *** 438,461 **** following characters escaped:: ! 1. The backslash character (as '\\') ! 2. The single quote (as "\'") ! 3. The <CR> character (as '\r') ! 4. The <NL> character (as '\n') ! 5. The <BS> character (as '\b') ! 6. The <FF> character (as '\f') ! 7. The <TAB> character (as '\t') ! 8. All other control characters as '\OOO' where OOO is ! the octal representation of the character's ordinal ! number. ! The string is also quoted with single quotes. ! ! If forArray is one (1), the escaping is changed as follows: ! 1. The backslash character (as '\\\\') ! (2 through 7 remain the same) ! 8. All other control characters as '\\\\000' ! 9. The double quote (as '\"') ! The string is also quoted with double quotes, instead of single ! quotes. *Returns*: --- 440,462 ---- following characters escaped:: ! 1. The backslash character (as '\\') ! 2. The single quote (as "\'") ! 3. The <CR> character (as '\r') ! 4. The <NL> character (as '\n') ! 5. The <BS> character (as '\b') ! 6. The <FF> character (as '\f') ! 7. The <TAB> character (as '\t') ! 8. All other control characters as '\OOO' where OOO is ! the octal representation of the character's ordinal ! number. ! The string is also quoted with single quotes. ! If forArray is one (1), the escaping is changed as follows: ! 1. The backslash character (as '\\\\') ! (2 through 7 remain the same) ! 8. All other control characters as '\\\\000' ! 9. The double quote (as '\"') ! The string is also quoted with double quotes, instead of single ! quotes. *Returns*: *************** *** 472,491 **** escaped as follows:: ! 1. <NUL> characters: '\\000' (Note: with 2 backslashes) ! 2. Non-printable characters: '\OOO' (Note OOO is the octal ! representation of the characters ordinal number) ! 3. Backslashes: '\\\\' (Note: with 4 backslashes) ! 4. Single quote: "\'" ! The string is also quoted with single quotes. ! If forArray is one (1), the escaping is changed as follows: ! 1. <NUL> characters: '\\\\000' (Note: with 4 backslashes) ! 2. Non-printable characters: '\\\\OOO' ! 3. Backslashes: '\\\\\\\\' (Note: with 8 backslashes) ! 4. Single quote: "\'" ! 5. The double quote (as '\\"') ! The string is also quoted with double quotes, instead of single ! quotes. *Returns*: --- 473,492 ---- escaped as follows:: ! 1. <NUL> characters: '\\000' (Note: with 2 backslashes) ! 2. Non-printable characters: '\OOO' (Note OOO is the octal ! representation of the characters ordinal number) ! 3. Backslashes: '\\\\' (Note: with 4 backslashes) ! 4. Single quote: "\'" ! The string is also quoted with single quotes. ! If forArray is one (1), the escaping is changed as follows: ! 1. <NUL> characters: '\\\\000' (Note: with 4 backslashes) ! 2. Non-printable characters: '\\\\OOO' ! 3. Backslashes: '\\\\\\\\' (Note: with 8 backslashes) ! 4. Single quote: "\'" ! 5. The double quote (as '\\"') ! The string is also quoted with double quotes, instead of single ! quotes. *Returns*: *************** *** 563,570 **** notices are placed in the list so that the list.pop() method will retrieve the oldest notice on the list. ! NOTE: While this attribute is read-only, you can still ! manipulate the list using any of the list's methods ! (pop, append, insert, etc.). You just can't assign ! a new value to the attribute. :version: version information about the backend that this connection object is connected to. --- 564,573 ---- notices are placed in the list so that the list.pop() method will retrieve the oldest notice on the list. ! ! :NOTE: While this attribute is read-only, you can still ! manipulate the list using any of the list's methods ! (pop, append, insert, etc.). You just can't assign ! a new value to the attribute. ! :version: version information about the backend that this connection object is connected to. *************** *** 818,822 **** the backend server) into a (dynamically sized) buffer. This method implements the PQgetline function and is used with the PostgreSQL COPY ! command.. *Exceptions*: --- 821,825 ---- the backend server) into a (dynamically sized) buffer. This method implements the PQgetline function and is used with the PostgreSQL COPY ! command. *Exceptions*: *************** *** 840,844 **** by the backend server) into a (dynamically sized) buffer. This method implements the PQgetline function and is used with the PostgreSQL COPY ! command.. *Exceptions*: --- 843,847 ---- by the backend server) into a (dynamically sized) buffer. This method implements the PQgetline function and is used with the PostgreSQL COPY ! command. *Exceptions*: *************** *** 860,864 **** The putline method sends a (null-terminated) string to the backend. This method implements the PQputline function and is used with the ! PostgreSQL COPY command.. *Exceptions*: --- 863,867 ---- The putline method sends a (null-terminated) string to the backend. This method implements the PQputline function and is used with the ! PostgreSQL COPY command. *Exceptions*: *************** *** 883,887 **** backend using getline. It must be issued or the backend may get "out of sync" with the frontend. This method implements the PQputline function ! and is used with the PostgreSQL COPY command.. *Exceptions*: --- 886,890 ---- backend using getline. It must be issued or the backend may get "out of sync" with the frontend. This method implements the PQputline function ! and is used with the PostgreSQL COPY command. *Exceptions*: *************** *** 1012,1016 **** tuple data, 0 if it contains ASCII data. It returns the output of the PQbinaryTuples function call. ! Note: Binary portals are not supported at this time. :cmdStatus: The command status string from the SQL command that generated the PGresult. It returns the output to the --- 1015,1021 ---- tuple data, 0 if it contains ASCII data. It returns the output of the PQbinaryTuples function call. ! ! :NOTE: Binary portals are not supported at this time. ! :cmdStatus: The command status string from the SQL command that generated the PGresult. It returns the output to the *************** *** 1304,1308 **** between binary and non-binary data. ! Note: 'w+' will NOT truncate the large object. *Note*: --- 1309,1313 ---- between binary and non-binary data. ! :NOTE: 'w+' will NOT truncate the large object. *Note*: *************** *** 1343,1349 **** *Description*: This method will export the PostgreSQL large object to the ! specified UNIX filename. Note: The file is stored on the ! database server, not the client machine (if different from ! the server). 2.1.4.4 The PgNotify Object --- 1348,1356 ---- *Description*: This method will export the PostgreSQL large object to the ! specified UNIX filename. ! ! *Note*: ! The file is stored on the database server, not the client machine (if ! different from the server). 2.1.4.4 The PgNotify Object *************** *** 1372,1390 **** object using the str() or repr() function. ! For example, for version 6.5.3, the contents of the PgVersion object would be:: ! connection.version == "PostgreSQL 6.5.3 on <system dependent info>" ! connection.version.major == 6 ! connection.version.minor == 5 ! connection.version.level == 3 ! connection.version.post70 == 0 ! For example, for version 7.1.1, the contents of PgVer would be:: ! connection.version == "PostgreSQL 7.1.1 on <system dependent info>" ! connection.version.major == 7 ! connection.version.minor == 1 ! connection.version.level == 1 ! connection.version.post70 == 1 Also, you can use the PgVersion object to compare against a number or string --- 1379,1401 ---- object using the str() or repr() function. ! For example, for version 6.5.3, the contents of the PgVersion object would be: ! :: ! connection.version == "PostgreSQL 6.5.3 on <system dependent info>" ! connection.version.major == 6 ! connection.version.minor == 5 ! connection.version.level == 3 ! connection.version.post70 == 0 ! For example, for version 7.1.1, the contents of PgVer would be: ! ! :: ! ! connection.version == "PostgreSQL 7.1.1 on <system dependent info>" ! connection.version.major == 7 ! connection.version.minor == 1 ! connection.version.level == 1 ! connection.version.post70 == 1 Also, you can use the PgVersion object to compare against a number or string *************** *** 1393,1413 **** An example: ! Assume that the PostgreSQL version is 7.0.2, then:: ! connection.version == 70002 will be true. ! connection.version < 70001L will be false. ! connection.version > 70001.0 will be true. You can also compare against a string as follows: ! Assume that the PostgreSQL version is 7.1.2, then:: ! connection.version == "7.0.2" will be false. ! connection.version < "7.0.1" will be false. ! connection.version > "7.1" will be true. ! Note: Both the libpq and PgSQL connection objects have the version attribute. ! Note: Comparisons against strings (i.e. "7.0.1") does not work in Python 2.0. 2.2 The PgSQL module --- 1404,1429 ---- An example: ! Assume that the PostgreSQL version is 7.0.2, then: ! :: ! ! connection.version == 70002 will be true. ! connection.version < 70001L will be false. ! connection.version > 70001.0 will be true. You can also compare against a string as follows: ! Assume that the PostgreSQL version is 7.1.2, then: ! :: ! connection.version == "7.0.2" will be false. ! connection.version < "7.0.1" will be false. ! connection.version > "7.1" will be true. ! :NOTE: Both the libpq and PgSQL connection objects have the version attribute. ! ! :NOTE: Comparisons against strings (i.e. "7.0.1") does not work in ! Python 2.0. 2.2 The PgSQL module *************** *** 1425,1432 **** the following statement: ! from pyPgSQL import PgSQL ! ! Note: This has change from previous releases of pyPgSQL where "import PgSQL" ! was used to import the module. 2.2.2 Differences at the Module Level --- 1441,1445 ---- the following statement: ! >>> from pyPgSQL import PgSQL 2.2.2 Differences at the Module Level *************** *** 1471,1475 **** a list plus adds a __quote__ method for quoting arrays. ! 3. The following class is defined: :PgVersion: Contains the version number of PostgreSQL database engine that --- 1484,1488 ---- a list plus adds a __quote__ method for quoting arrays. ! 4. The following class is defined: :PgVersion: Contains the version number of PostgreSQL database engine that *************** *** 1479,1483 **** PgVersion object. ! 4. The following constructors are defined by the PgSQL module. :PgBoolean: Construct a PgBoolean from a Python numeric or string. --- 1492,1496 ---- PgVersion object. ! 5. The following constructors are defined by the PgSQL module. :PgBoolean: Construct a PgBoolean from a Python numeric or string. *************** *** 1489,1493 **** These constructors are documented in the libpq section of this document. ! 5. The following attribute is defined in the PgSQL module: :fetchReturnsList: controls the type of result returns by the fetchXXX --- 1502,1506 ---- These constructors are documented in the libpq section of this document. ! 6. The following attribute is defined in the PgSQL module: :fetchReturnsList: controls the type of result returns by the fetchXXX *************** *** 1506,1511 **** This attribute is a list of notices returned by the pq library. ! Note: Under normal usage, certain (but not all) notices received from the ! libpq C-API library are converted into Warning exceptions. 2. The Connection object has an additional read-only attribute called version. --- 1519,1524 ---- This attribute is a list of notices returned by the pq library. ! :NOTE: Under normal usage, certain (but not all) notices received from ! the libpq C-API library are converted into Warning exceptions. 2. The Connection object has an additional read-only attribute called version. *************** *** 1524,1529 **** "READ COMMITED", or "SERIALIZABLE". PgSQL will issue the appropriate "SET TRANSACTION LEVEL" statement whenever a new transaction is started for ! the connection. Note: The value of this attribute can not be changed if ! there are any active cursors for the connection. 2.2.3.1 unlink --- 1537,1544 ---- "READ COMMITED", or "SERIALIZABLE". PgSQL will issue the appropriate "SET TRANSACTION LEVEL" statement whenever a new transaction is started for ! the connection. ! ! :NOTE: The value of this attribute can not be changed if there are any ! active cursors for the connection. 2.2.3.1 unlink *************** *** 1554,1560 **** result set (or nothing). ! NOTE: Beginning with PostgreSQL 7.2, it is possible to return a refer- ! ence to a cursor from PL/pgSQL. PgSQL will create a new Cursor ! object for the referenced cursor that is returned. 3. When using the execute method, you should only use '%s' [or '%(name)s'] --- 1569,1575 ---- result set (or nothing). ! :NOTE: Beginning with PostgreSQL 7.2, it is possible to return a ! reference to a cursor from PL/pgSQL. PgSQL will create a new ! Cursor object for the referenced cursor that is returned. 3. When using the execute method, you should only use '%s' [or '%(name)s'] *************** *** 1569,1579 **** using the column name as an attribute of the PgResultSet object. The column names are case-insensitive. ! [Note: This feature is controlled by the fetchReturnsList attribute of ! the PgSQL module.] 5. The fetchmany and fetchall methods return a sequence of PgResultSet objects instead of a sequence of sequences. ! [Note: This feature is controlled by the fetchReturnsList attribute of ! the PgSQL module.] 6. A PostgreSQL specific attribute, named oidValue, was added to the cursor --- 1584,1596 ---- using the column name as an attribute of the PgResultSet object. The column names are case-insensitive. ! ! :NOTE: This feature is controlled by the fetchReturnsList attribute of ! the PgSQL module. 5. The fetchmany and fetchall methods return a sequence of PgResultSet objects instead of a sequence of sequences. ! ! :NOTE: This feature is controlled by the fetchReturnsList attribute of ! the PgSQL module. 6. A PostgreSQL specific attribute, named oidValue, was added to the cursor *************** *** 1582,1585 **** --- 1599,1603 ---- way to get the object ID of a newly inserted record. + ================================== 3.0 General Notes and Observations ================================== *************** *** 1587,1600 **** The PostgreSQL database system has no auto-commit setting. It is always in auto-commit mode unless a transaction is started. To achieve the DB-API 2.0 ! mandated behaviour, when connection.autocommit is 0, a transaction is started ! when the first cursor is created for a connection. After a commit or rollback, ! a new transaction is created on the next call to execute(). ! ---------- ! PostgreSQL arrays are no longer (directly) represented by Python lists. This ! means that lists and tuples are not longer treated specially by Cursor.execute(). This resolves 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: --- 1605,1620 ---- The PostgreSQL database system has no auto-commit setting. It is always in auto-commit mode unless a transaction is started. To achieve the DB-API 2.0 ! mandated behaviour, when connection.autocommit is 0, a transaction is ! started when the first cursor is created for a connection. After a commit ! or rollback, a new transaction is created on the next call to execute(). ! ! ---------------------------------------------------------------------------- ! ! PostgreSQL arrays are no longer (directly) represented by Python lists. ! This means that lists and tuples are not longer treated specially by Cursor.execute(). This resolves 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: *************** *** 1603,1627 **** 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. The code will try to ensure that a transaction is active while working with large object (i.e. lo_open will start a transaction if necessary. lo_close will end the transaction if it determines that lo_open started one.) ! ---------- Beginning with PostgreSQL 7.2, you can now create a cursor in PL/pgSQL and ! return a reference to that cursor. PgSQL will transform the reference to the ! created cursor into a Cursor object that can be used to fetch the results of ! the cursor. For example (assuming that mmYearInfo returns a reference cursor): - $ python - Python 2.2.2 (#7, Nov 27 2002, 17:10:05) [C] on openunix8 - Type "help", "copyright", "credits" or "license" for more information. >>> from pyPgSQL import PgSQL >>> cx = PgSQL.connect(database='esi') --- 1623,1649 ---- 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. The code will try to ensure that a transaction is active while working with large object (i.e. lo_open will start a transaction if necessary. lo_close will end the transaction if it determines that lo_open started one.) ! ! ---------------------------------------------------------------------------- ! Beginning with PostgreSQL 7.2, you can now create a cursor in PL/pgSQL and ! return a reference to that cursor. PgSQL will transform the reference to ! the created cursor into a Cursor object that can be used to fetch the ! results of the cursor. For example (assuming that mmYearInfo returns a ! reference cursor): >>> from pyPgSQL import PgSQL >>> cx = PgSQL.connect(database='esi') |
From: Billy G. A. <bal...@us...> - 2002-12-05 04:22:05
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv15180/pyPgSQL Modified Files: PgSQL.py Log Message: 04DEC2002 bga Fixed problems with PgNumeric that were missed in yesterday's patch. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PgSQL.py 4 Dec 2002 07:08:44 -0000 1.26 --- PgSQL.py 5 Dec 2002 04:22:02 -0000 1.27 *************** *** 30,33 **** --- 30,35 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 04DEC2002 bga - Correct some problems that were missed in yesterday's | + # fixes (Thanks, Adam, for the help with the problems) | # 03DEC2002 bga - Fixed various problems with the constructor and the | # formatting routine. These correct the problems re- | *************** *** 1216,1219 **** --- 1218,1229 ---- else: self.__v = long(value) + # Check to see if the value is too large for the given + # precision/scale + _v = str(value) + if _v[-1:] == 'L': + _v = _v[:-1] + if len(_v) > prec: + raise OverflowError, "value too large for PgNumeric" + self.__p = prec self.__s = scale *************** *** 1241,1251 **** _d = _v.rfind('.') _e = _v.rfind('e') _ip = _v[:_d] ! if _e >= 0: ! _fp = _v[_d+1:_e] ! _xp = _v[_e+1:] ! else: ! _fp = _v[_d+1:] ! _xp = '' # Check the validity of the input --- 1251,1265 ---- _d = _v.rfind('.') _e = _v.rfind('e') + + # Ensure that _e and _v contains a sane value + if _e < 0: + _e = len(_v) + + if _d < 0: + _d = _e + _ip = _v[:_d] ! _fp = _v[_d+1:_e] ! _xp = _v[_e+1:] # Check the validity of the input *************** *** 1270,1279 **** # Create the string that will become the base (long) object ! _v = _ip + _fp _sc = len(_fp) if _exp > 0: if _exp > _sc: ! _v = _v + ("0" * (_exp - _sc + 1)) _sc = 0 else: --- 1284,1293 ---- # Create the string that will become the base (long) object ! _v = _ip + _fp _sc = len(_fp) if _exp > 0: if _exp > _sc: ! _v = _v + ("0" * (_exp - _sc)) _sc = 0 else: *************** *** 1353,1359 **** def __fmtNumeric(self, value=None): - # Check to see if the string representation of the python long has - # a trailing 'L', if so, remove it. Python 1.5 has the trailing 'L', - # Python 1.6 does not. if value is None: _v = self.__v --- 1367,1370 ---- *************** *** 1369,1372 **** --- 1380,1386 ---- _v = str(_v) + # Check to see if the string representation of the python long has + # a trailing 'L', if so, remove it. Python 1.5 has the trailing 'L', + # Python 1.6 does not. if _v[-1:] == 'L': _v = _v[:-1] |
From: Billy G. A. <bal...@us...> - 2002-12-04 07:08:46
|
Update of /cvsroot/pypgsql/pypgsql/pyPgSQL In directory sc8-pr-cvs1:/tmp/cvs-serv14980/pyPgSQL Modified Files: PgSQL.py Log Message: 03DEC2002 bga Fixed various problems with the constructor and the formatting routine. These correct the problems reported by Adam Buraczewski. Index: PgSQL.py =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/pyPgSQL/PgSQL.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PgSQL.py 1 Dec 2002 22:12:30 -0000 1.25 --- PgSQL.py 4 Dec 2002 07:08:44 -0000 1.26 *************** *** 30,33 **** --- 30,36 ---- # Date Ini Description | # --------- --- ------------------------------------------------------- | + # 03DEC2002 bga - Fixed various problems with the constructor and the | + # formatting routine. These correct the problems re- | + # ported by Adam Buraczewski. | # 01DEC2002 bga - Fixed problems with new __setupTransaction function: | # 1. Made it a method of Connection, not Cursor. | *************** *** 1215,1300 **** self.__p = prec self.__s = scale ! elif type(value) is FloatType: ! _s = repr(value) ! _d = _s.rfind('.') ! _e = _s.rfind('e') ! _exp = 0 ! if (_e >= 0): ! _exp = int(_s[_e+1:]) ! _s = _s[:_e] ! if _exp > 31: ! raise OverflowError, "float too large for PgNumeric" ! if _exp < -31: ! raise OverflowError, "float too small for PgNumeric" ! _s = _s[:_d] + _s[_d+1:] ! if _exp == 0: ! _sc = len(_s) - _d ! elif _exp > 0: ! _s = _s + ("0" * (_exp - len(_s) + 1)) ! _sc = 0 ! else: ! _sc = -_exp + len(_s) - 1 ! self.__v = long(_s) ! self.__p = len(_s) ! if self.__p < _sc: ! self.__p = _sc ! self.__s = _sc ! elif type(value) is StringType: ! _v = value.split() ! if len(_v) == 0 or len(_v) > 1: ! raise ValueError, \ ! "invalid literal for PgNumeric: %s" % value ! _v = _v[0] ! # At this point _v is value with leading and trailing blanks ! # removed. Initalize the precision and scale values. They will be ! # determined from the input string (value) is prec and scale are ! # None. ! _vs = value.rfind('.') # Get the location of the decimal point. ! # It's used to determine the precision and ! if prec: # scale if they aren't passed in, and to ! self.__p = prec # adjust the input string to match the ! else: # passed in scale. ! self.__p = len(value) ! if _vs >= 0: ! self.__p = self.__p - 1 ! # Calculate the scale of the passed in string. _vs will contain the ! # calulated scale. ! if _vs >= 0: ! _vs = len(value) - _vs - 1 ! else: ! _vs = 0 ! ! if scale: ! self.__s = scale ! else: ! self.__s = _vs ! # Calculate the number of character to add/remove from the end of ! # the input string in order to have it match the given scale. _sd ! # will contain the number of characters to add (>0) or remove (<0). ! _sd = self.__s - _vs ! if _sd == 0: ! pass # No change to value needed. ! elif _sd > 0: ! _v = _v + ('0' * _sd) # Add needed zeros to the end of value ! else: ! _v = _v[:_sd] # Remove excess digits from the end. ! if self.__s: ! _s = _v[:-(self.__s + 1)] + _v[-self.__s:] else: ! _s = _v ! try: ! self.__v = long(_s) except: raise ValueError, \ "invalid literal for PgNumeric: %s" % value elif isinstance(value, PgNumeric): # This is used to "cast" a PgNumeric to the specified precision --- 1218,1319 ---- self.__p = prec self.__s = scale ! elif type(value) in (FloatType, StringType): ! # Get the value to convert as a string. ! # The expected input is in the form of [+|-][d]*[.[d]*][e[d]+] ! # First get the value as a (trimmed) string ! if type(value) is FloatType: ! _v = repr(value) ! else: ! _v = value.split() ! if len(_v) == 0 or len(_v) > 1: ! raise ValueError, \ ! "invalid literal for PgNumeric: %s" % value ! _v = _v[0] ! ! # Save the sign character (if any) and remove from the string ! _sign = '+' ! if _v[0] in ('-', '+'): ! _sign = _v[0] ! _v = _v[1:] ! # Split the remaining string into int part, frac part and exponet ! _d = _v.rfind('.') ! _e = _v.rfind('e') ! _ip = _v[:_d] ! if _e >= 0: ! _fp = _v[_d+1:_e] ! _xp = _v[_e+1:] ! else: ! _fp = _v[_d+1:] ! _xp = '' ! # Check the validity of the input ! if len(_ip) == 0 and len(_fp) == 0: ! raise ValueError, \ ! "invalid literal for PgNumeric: %s" % value ! if len(_xp) > 0: ! try: ! _exp = int(_xp) ! except: ! raise ValueError, \ ! "invalid literal for PgNumeric: %s" % value ! else: ! _exp = 0 ! if _exp > 999: ! raise OverflowError, "value too large for PgNumeric" ! if _exp < -999: ! raise OverflowError, "value too small for PgNumeric" ! # Create the string that will become the base (long) object ! _v = _ip + _fp ! _sc = len(_fp) ! if _exp > 0: ! if _exp > _sc: ! _v = _v + ("0" * (_exp - _sc + 1)) ! _sc = 0 ! else: ! _sc = _sc - _exp else: ! _sc = _sc - _exp ! try: ! self.__v = long(_sign + _v) except: raise ValueError, \ "invalid literal for PgNumeric: %s" % value + + self.__p = len(_v) + if self.__p < _sc: + self.__p = _sc + self.__s = _sc + + # Now adjust for the inputted scale (if any) + if scale is None: + pass + else: + _adj = scale - self.__s + if _adj > 0: + self.__v = self.__v * (10L ** (scale - self.__s)) + elif _adj < 0: + self.__v = self._round(self.__v, -_adj) + + self.__p = self.__p + _adj + self.__s = scale + + # Apply the inputted precision (if any) + if prec is None: + pass + else: + if prec > 1000: + raise ValueError, "precision too large for PgNumeric" + elif self.__p > prec: + raise OverflowError, "value too large for PgNumeric" + else: + self.__p = prec elif isinstance(value, PgNumeric): # This is used to "cast" a PgNumeric to the specified precision *************** *** 1318,1322 **** self.__v = self.__v * (10L ** _ds) elif _ds < 0: ! self.__v = self._round(self.__v, abs(_ds)) if self.__v > (10L ** self.__p): raise OverflowError, "result exceeds precision of %d" % self.__p --- 1337,1341 ---- self.__v = self.__v * (10L ** _ds) elif _ds < 0: ! self.__v = self._round(self.__v, -_ds) if self.__v > (10L ** self.__p): raise OverflowError, "result exceeds precision of %d" % self.__p *************** *** 1324,1327 **** --- 1343,1350 ---- raise TypeError, "value can not be converted to a PgNumeric." + if self.__s > self.__p: + raise ValueError, \ + "scale of %d exceeds precision of %d" % (self.__s, self.__p) + # The value (10L ** self.__s) is used a lot. Save it as a constant # to save a (small) bit of time. *************** *** 1334,1355 **** # Python 1.6 does not. if value is None: ! _v = str(self.__v) else: ! _v = str(value) if _v[-1:] == 'L': _v = _v[:-1] ! # Check to see if the numeric is less than zero and fix string if so. if len(_v) <= self.__s: _v = ("0" * (self.__s - len(_v) + 1)) + _v if self.__s: ! _s = "%s.%s" % (_v[:-(self.__s)], _v[-(self.__s):]) else: ! _s = "%s" % _v return _s def __repr__(self): ! return "<PgNumeric instance - precision: %d scale: %d value: %s" % \ (self.__p, self.__s, self.__fmtNumeric()) --- 1357,1387 ---- # Python 1.6 does not. if value is None: ! _v = self.__v else: ! _v = value ! ! # Check for a negative value and adjust if necessary ! if _v < 0: ! _sign = '-' ! _v = -_v ! else: ! _sign = '' ! _v = str(_v) ! if _v[-1:] == 'L': _v = _v[:-1] ! # Check to see if the numeric is less than one and fix string if so. if len(_v) <= self.__s: _v = ("0" * (self.__s - len(_v) + 1)) + _v if self.__s: ! _s = "%s%s.%s" % (_sign, _v[:-(self.__s)], _v[-(self.__s):]) else: ! _s = "%s%s" % (_sign, _v) return _s def __repr__(self): ! return "<PgNumeric instance - precision: %d scale: %d value: %s>" % \ (self.__p, self.__s, self.__fmtNumeric()) |