mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-10 19:16:34 +03:00
License changes. Fixes. Added register_adapter().
This commit is contained in:
parent
9bf185f6a9
commit
1141149cd3
25
ChangeLog
25
ChangeLog
|
@ -1,3 +1,28 @@
|
|||
2005-01-20 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* lib/extensions.py (register_adapter): added register_adapter
|
||||
function, exported ISQLQuote in psycopg.extensions.
|
||||
|
||||
2005-01-18 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/pqpath.c (_pq_fetch_tuples): ported scale/precision fix
|
||||
from psycopg 1.1.
|
||||
|
||||
* LICENSE: detailed licensing information. Re-licensed some parts
|
||||
under BSD-like to allow integration is pysqlite.
|
||||
|
||||
2005-01-13 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* ZPsycopgDA/db.py (DB.query): ported ZPsycopgDA connection fix
|
||||
from psycopg 1.1.
|
||||
|
||||
* lib/*.py: added pydoc-friendly messages.
|
||||
|
||||
2005-01-12 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* Added debian directory (thanks to W. Borgert who sent initial
|
||||
patch based on cdbs.)
|
||||
|
||||
2004-12-20 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
* psycopg/pqpath.c (pq_execute): removed multiple calls to
|
||||
|
|
35
LICENSE
Normal file
35
LICENSE
Normal file
|
@ -0,0 +1,35 @@
|
|||
psycopg is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version. See file COPYING for details.
|
||||
|
||||
As a special exception, specific permission is granted for the GPLed
|
||||
code in this distribition to be linked to OpenSSL and PostgreSQL libpq
|
||||
without invoking GPL clause 2(b).
|
||||
|
||||
If you prefer you can use the Zope Database Adapter ZPsycopgDA (i.e.,
|
||||
every file inside the ZPsycopgDA directory) user the ZPL license as
|
||||
published on the Zope web site, http://www.zope.org/Resources/ZPL.
|
||||
|
||||
Also, the following BSD-like license applies (at your option) to the
|
||||
files following the pattern psycopg/adapter*.{h,c} and
|
||||
psycopg/microprotocol*.{h,c}:
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not
|
||||
be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
psycopg is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
13
NEWS
13
NEWS
|
@ -1,3 +1,16 @@
|
|||
What's new in psycopg 1.99.12
|
||||
-----------------------------
|
||||
|
||||
* .rowcount should be ok and in sync with psycopg 1.
|
||||
|
||||
* Strings can contain NULLs and are quoted accordingly.
|
||||
|
||||
* Implemented the new COPY FROM/COPY TO code when connection to the
|
||||
backend using libpq protocol 3 (this also removes all asprintf calls:
|
||||
build on win32 works again.) A protocol 3-enabled psycopg *can*
|
||||
connect to an old protocol 2 database and will detect it and use the
|
||||
right code.
|
||||
|
||||
What's new in psycopg 1.99.11
|
||||
-----------------------------
|
||||
|
||||
|
|
|
@ -162,11 +162,26 @@ class DB(TM, dbi_db.DB):
|
|||
if self.encoding:
|
||||
qs = qs.encode(self.encoding)
|
||||
try:
|
||||
if (query_data):
|
||||
if query_data:
|
||||
c.execute(qs, query_data)
|
||||
else:
|
||||
c.execute(qs)
|
||||
except (psycopg.ProgrammingError, psycopg.IntegrityError), e:
|
||||
except OperationalError, e:
|
||||
try:
|
||||
self.close()
|
||||
except:
|
||||
pass
|
||||
self.open()
|
||||
try:
|
||||
if query_data:
|
||||
c.execute(qs, query_data)
|
||||
else:
|
||||
c.execute(qs)
|
||||
except (psycopg.ProgrammingError,psycopg.IntegrityError),e:
|
||||
if e.args[0].find("concurrent update") > -1:
|
||||
raise ConflictError
|
||||
raise e
|
||||
except (psycopg.ProgrammingError,psycopg.IntegrityError), e:
|
||||
if e.args[0].find("concurrent update") > -1:
|
||||
raise ConflictError
|
||||
raise e
|
||||
|
|
12
debian/changelog
vendored
Normal file
12
debian/changelog
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
psycopg2 (1.99.11-1) experimental; urgency=low
|
||||
|
||||
* Adapted from patches sent by W. Borgert.
|
||||
* Renamed source package to psycopg2.
|
||||
|
||||
--
|
||||
|
||||
psycopg2 (1.99.11-0.1) unstable; urgency=low
|
||||
|
||||
* Experimental package.
|
||||
|
||||
-- W. Borgert <debacle@debian.org> Sun, 09 Jan 2005 10:14:09 +0000
|
51
debian/control
vendored
Normal file
51
debian/control
vendored
Normal file
|
@ -0,0 +1,51 @@
|
|||
Source: psycopg2
|
||||
Section: python
|
||||
Priority: optional
|
||||
Build-depends: postgresql-dev, debhelper (>> 3), python2.3-dev, cdbs
|
||||
Maintainer: Federico Di Gregorio <fog@debian.org>
|
||||
Standards-Version: 3.6.1.1
|
||||
|
||||
Package: python-psycopg2
|
||||
Architecture: any
|
||||
Section: python
|
||||
Depends: python (>= 2.3), python (<< 2.4), python2.3-psycopg
|
||||
Description: Python module for PostgreSQL [dummy package]
|
||||
psycopg is a PostgreSQL database adapter for the Python programming
|
||||
language. It was written from scratch with the aim of being very small
|
||||
and fast, and stable as a rock. The main advantages of psycopg are that
|
||||
it supports the full Python DBAPI-2.0 and being thread safe at level 2.
|
||||
.
|
||||
psycopg 2 is the next generation psycopg, implementing a much better
|
||||
type system and even more DBAPI extensions:
|
||||
.
|
||||
* support for Python datetime and Decimal types;
|
||||
* complete implementation of adapt() from PEP 246 to convert Python
|
||||
types to PostgreSQL ones;
|
||||
* COPY FROM/COPY TO support
|
||||
* inehritable connection and cursor objects and support for connection
|
||||
and cursor factories;
|
||||
* automatic encoding conversion and support for unicode queries.
|
||||
.
|
||||
This dummy package just depends on the right, default version of Python
|
||||
and psycopg 2.
|
||||
|
||||
Package: python2.3-psycopg2
|
||||
Architecture: any
|
||||
Section: python
|
||||
Depends: ${shlibs:Depends}, python2.3
|
||||
Description: Python 2.3 module for PostgreSQL
|
||||
psycopg is a PostgreSQL database adapter for the Python programming
|
||||
language. It was written from scratch with the aim of being very small
|
||||
and fast, and stable as a rock. The main advantages of psycopg are that
|
||||
it supports the full Python DBAPI-2.0 and being thread safe at level 2.
|
||||
.
|
||||
psycopg 2 is the next generation psycopg, implementing a much better
|
||||
type system and even more DBAPI extensions:
|
||||
.
|
||||
* support for Python datetime and Decimal types;
|
||||
* complete implementation of adapt() from PEP 246 to convert Python
|
||||
types to PostgreSQL ones;
|
||||
* COPY FROM/COPY TO support
|
||||
* inehritable connection and cursor objects and support for connection
|
||||
and cursor factories;
|
||||
* automatic encoding conversion and support for unicode queries.
|
10
debian/copyright
vendored
Normal file
10
debian/copyright
vendored
Normal file
|
@ -0,0 +1,10 @@
|
|||
psycopg can be downloaded from its homepage:
|
||||
|
||||
http://initd.org/pub/software/psycopg/ALPHA/
|
||||
|
||||
Copyright (c) 2001-2005 Federico Di Gregorio <fog@debian.org>
|
||||
|
||||
This program is distributed under the GNU GPL.
|
||||
|
||||
On Debian GNU/Linux systems, the complete text of the GNU General
|
||||
Public License can be found in '/usr/share/common-licenses/GPL'.
|
5
debian/rules
vendored
Executable file
5
debian/rules
vendored
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
include /usr/share/cdbs/1/rules/debhelper.mk
|
||||
include /usr/share/cdbs/1/class/python-distutils.mk
|
||||
|
|
@ -1,3 +1,11 @@
|
|||
"""A Python driver for PostgreSQL
|
||||
|
||||
psycopg is a PostgreSQL database adapter for the Python programming
|
||||
language. This is version 2, a complete rewrite of the original code to
|
||||
provide new-style classes for connection and cursor objects and other sweet
|
||||
candies. Like the original, psycopg 2 was written with the aim of being very
|
||||
small and fast, and stable as a rock.
|
||||
"""
|
||||
# psycopg/__init__.py - initialization of the psycopg module
|
||||
#
|
||||
# Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
"""
|
||||
psycopg extensions to the DBAPI-2.0
|
||||
|
||||
This module holds all the extensions to the DBAPI-2.0 provided by psycopg:
|
||||
|
||||
connection -- the new-type inheritable connection class
|
||||
cursor -- the new-type inheritable cursor class
|
||||
adapt() -- exposes the PEP-246 compatile adapting machanism used
|
||||
by psycopg to adapt Python types to PostgreSQL ones
|
||||
"""
|
||||
# psycopg/extensions.py - DBAPI-2.0 extensions specific to psycopg
|
||||
#
|
||||
# Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
|
||||
|
@ -29,3 +39,9 @@ except:
|
|||
|
||||
from _psycopg import adapt, adapters, encodings, connection, cursor
|
||||
from _psycopg import string_types, binary_types, new_type, register_type
|
||||
from _psycopg import ISQLQuote
|
||||
|
||||
|
||||
def register_adapter(typ, callable):
|
||||
"""Register 'callable' as an ISQLQuote adapter for type 'typ'."""
|
||||
adapters[(typ, ISQLQuote)] = callable
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
"""Miscellaneous goodies for psycopg
|
||||
|
||||
This module is a generic place used to hold little helper function
|
||||
and classes untill a better place in the distribution is found.
|
||||
"""
|
||||
# psycopg/extras.py - miscellaneous extra goodies for psycopg
|
||||
#
|
||||
# Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
"""Connection pooling for psycopg
|
||||
|
||||
This module implements thread-safe (and not) connection pools.
|
||||
"""
|
||||
# psycopg/pool.py - pooling code for psycopg
|
||||
#
|
||||
# Copyright (C) 2003-2004 Federico Di Gregorio <fog@debian.org>
|
||||
|
|
|
@ -895,6 +895,15 @@ psyco_curs_scroll(cursorObject *self, PyObject *args, PyObject *kwargs)
|
|||
#define psyco_curs_copy_from_doc \
|
||||
"copy_from(file, table, sep='\\t', null='NULL') -> copy file to table."
|
||||
|
||||
static int
|
||||
_psyco_curs_copy_from_check(PyObject *o)
|
||||
{
|
||||
if (PyObject_GetAttrString(o, "write")
|
||||
return 1;
|
||||
else
|
||||
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
psyco_curs_copy_from(cursorObject *self, PyObject *args)
|
||||
{
|
||||
|
|
|
@ -538,7 +538,7 @@ _pq_fetch_tuples(cursorObject *curs)
|
|||
/* 4,5/ scale and precision */
|
||||
if (ftype == NUMERICOID) {
|
||||
PyTuple_SET_ITEM(dtitem, 4, PyInt_FromLong((fmod >> 16) & 0xFFFF));
|
||||
PyTuple_SET_ITEM(dtitem, 5, PyInt_FromLong(fmod & 0xFFFF));
|
||||
PyTuple_SET_ITEM(dtitem, 5, PyInt_FromLong(fmod & 0xFFFF) - 4);
|
||||
}
|
||||
else {
|
||||
Py_INCREF(Py_None);
|
||||
|
@ -557,7 +557,7 @@ _pq_fetch_tuples(cursorObject *curs)
|
|||
|
||||
#ifdef HAVE_PQPROTOCOL3
|
||||
static int
|
||||
_pq_copy_in(cursorObject *curs)
|
||||
_pq_copy_in_v3(cursorObject *curs)
|
||||
{
|
||||
/* COPY FROM implementation when protocol 3 is available: this function
|
||||
uses the new PQputCopyData() and can detect errors and set the correct
|
||||
|
@ -565,7 +565,7 @@ _pq_copy_in(cursorObject *curs)
|
|||
|
||||
return -1;
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
static int
|
||||
_pq_copy_in(cursorObject *curs)
|
||||
{
|
||||
|
@ -589,11 +589,10 @@ _pq_copy_in(cursorObject *curs)
|
|||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_PQPROTOCOL3
|
||||
static int
|
||||
_pq_copy_out(cursorObject *curs)
|
||||
_pq_copy_out_v3(cursorObject *curs)
|
||||
{
|
||||
char *buffer;
|
||||
int len;
|
||||
|
@ -620,7 +619,8 @@ _pq_copy_out(cursorObject *curs)
|
|||
|
||||
return 1;
|
||||
}
|
||||
#else
|
||||
#endif
|
||||
|
||||
static int
|
||||
_pq_copy_out(cursorObject *curs)
|
||||
{
|
||||
|
@ -655,7 +655,7 @@ _pq_copy_out(cursorObject *curs)
|
|||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
pq_fetch(cursorObject *curs)
|
||||
|
@ -747,7 +747,12 @@ pq_fetch(cursorObject *curs)
|
|||
case PGRES_COPY_OUT:
|
||||
Dprintf("pq_fetch: data from a COPY TO (no tuples)");
|
||||
curs->rowcount = 0;
|
||||
ex = _pq_copy_out(curs);
|
||||
#ifdef HAVE_PQPROTOCOL3
|
||||
if (curs->conn->protocol == 3)
|
||||
ex = _pq_copy_out_3(curs);
|
||||
else
|
||||
#endif
|
||||
ex = _pq_copy_out(curs);
|
||||
/* error caught by out glorious notice handler */
|
||||
if (PyErr_Occurred()) ex = -1;
|
||||
IFCLEARPGRES(curs->pgres);
|
||||
|
@ -756,7 +761,12 @@ pq_fetch(cursorObject *curs)
|
|||
case PGRES_COPY_IN:
|
||||
Dprintf("pq_fetch: data from a COPY FROM (no tuples)");
|
||||
curs->rowcount = 0;
|
||||
ex = _pq_copy_in(curs);
|
||||
#ifdef HAVE_PQPROTOCOL3
|
||||
if (curs->conn->protocol == 3)
|
||||
ex = _pq_copy_in_v3(curs);
|
||||
else
|
||||
#endif
|
||||
ex = _pq_copy_in(curs);
|
||||
/* error caught by out glorious notice handler */
|
||||
if (PyErr_Occurred()) ex = -1;
|
||||
IFCLEARPGRES(curs->pgres);
|
||||
|
|
Loading…
Reference in New Issue
Block a user