Commit Graph

214 Commits

Author SHA1 Message Date
Daniele Varrazzo
95226baa9b Further minimal performance tweaks to execute_values 2017-02-02 17:44:25 +00:00
Daniele Varrazzo
dc1b4fff90 Avoid an useless encode/decode roundtrip in execute_values()
Tests moved into a separate module.
2017-02-02 17:29:17 +00:00
Daniele Varrazzo
d2fdc5ca9f Better docs for fast executemany functions.
Issue #502.
2017-02-02 16:02:33 +00:00
Daniele Varrazzo
9bac37baf7 Fixed execute_values with unicode
Also added unicode tests.
2017-02-01 02:47:59 +00:00
Daniele Varrazzo
2e2dcd536b Fixed fast execute functions with Python 3 2017-02-01 02:36:54 +00:00
Daniele Varrazzo
a95fd3df1a Added execute_batch and execute_values functions 2017-02-01 01:59:47 +00:00
NotSqrt
9ffb61214c Fix DeprecationWarning: generator '__iter__' raised StopIteration
Closes #498
2017-01-04 09:45:53 +01:00
Daniele Varrazzo
21f38a4c07 Don't try to write bytes in the LoggingConnection file
Close #483
2016-12-29 22:42:25 +01:00
Tim Graham
35b4a01b6d Fix "invalid escape sequence" warning in Python 3.6
http://bugs.python.org/issue27364
2016-12-25 20:43:29 +01:00
Daniele Varrazzo
643ba70bad Added ipaddress objects conversion
Close #387
2016-10-11 04:54:41 +01:00
Daniele Varrazzo
86198c1c21 inet adapters deprecated
Close #343
2016-10-11 02:17:56 +01:00
Daniele Varrazzo
91d2158de7 Python source cleanup using flake8 2016-10-11 00:11:55 +01:00
Daniele Varrazzo
78649f8e90 Dropped use of b() "macro" and 2to3 fixer
Just use the b"" strings syntax supported from python 2.6.
2016-08-15 01:56:36 +01:00
Oleksandr Shulgin
b21c8f7a4e Move replication-related imports to extras.py 2016-03-08 18:52:29 +01:00
Oleksandr Shulgin
da6e061ee8 Use python-defined make_dsn() for ReplicationConnection class 2016-03-08 18:52:21 +01:00
Oleksandr Shulgin
fbcf99ad07 Move replication connection to C level. 2015-10-27 18:21:24 +01:00
Oleksandr Shulgin
e69dafbecc Move the decode parameter to start_replication().
It makes more sense this way, because otherwise it must be passed to every call
of `read_message()`.
2015-10-23 11:31:55 +02:00
Oleksandr Shulgin
23abe4f501 Add quick start to the replication doc, minor doc fixes. 2015-10-20 12:36:13 +02:00
Oleksandr Shulgin
0bb81fc848 Properly subclass ReplicationCursor on C level. 2015-10-19 20:00:39 +02:00
Oleksandr Shulgin
4ab7cf0157 Replace stop_replication with requirement for an exception. 2015-10-19 15:42:42 +02:00
Oleksandr Shulgin
cf4f2411bf Fix async replication and test. 2015-10-15 18:01:43 +02:00
Oleksandr Shulgin
d14fea31a3 Use quote_ident from psycopg2.extensions 2015-10-15 12:56:21 +02:00
Oleksandr Shulgin
8e518d4954 Merge branch 'master' into feature/replication-protocol 2015-10-15 12:27:43 +02:00
Oleksandr Shulgin
6ad299945f Remove IDENTIFY_SYSTEM wrapper method (it can't work with async anyway). 2015-10-13 18:05:33 +02:00
Oleksandr Shulgin
0233620c26 Rework replication connection/cursor classes 2015-10-01 19:33:27 +02:00
Oleksandr Shulgin
cac83da5db Use parse_dsn in ReplicationConnectionBase 2015-10-01 19:33:24 +02:00
Oleksandr Shulgin
95ee218c6d Update replication connection/cursor interface and docs. 2015-10-01 19:33:20 +02:00
Oleksandr Shulgin
937a7a9024 Cleanup start replication wrt. slot type a bit. 2015-10-01 19:33:16 +02:00
Daniele Varrazzo
f635547ec6 The wait_select callback can cancel a query using Ctrl-C
Fixes #333.
2015-10-01 15:26:13 +01:00
Oleksandr Shulgin
61e52ce879 Rework replication protocol
This change exposes lower level functions for operating the
(logical) replication protocol, while keeping the high-level
start_replication function that does all the job for you in
case of a synchronous connection.

A number of other changes and fixes are put into this commit.
2015-06-30 10:38:18 +02:00
Oleksandr Shulgin
35a3262fe3 Expose ReplicationMessage type in extras 2015-06-11 12:20:52 +02:00
Oleksandr Shulgin
1ac385d1fb Fix logical decoding plugin options adaptation on python3 2015-06-10 13:39:35 +02:00
Oleksandr Shulgin
453830f80c Add ReplicationMessage object 2015-06-05 17:44:09 +02:00
Oleksandr Shulgin
44b705f88f Improve identify_system: don't hardcode column names 2015-06-02 16:52:48 +02:00
Oleksandr Shulgin
e32e1b834e Add support for streaming replication protocol
Introduce ReplicationConnection and ReplicationCursor classes, that
incapsulate initiation of special type of PostgreSQL connection and
handling of special replication commands only available in this special
connection mode.

The handling of stream of replication data from the server is modelled
largely after the existing support for "COPY table TO file" command and
pg_recvlogical tool supplied with PostgreSQL (though, it can also be
used for physical replication.)
2015-06-01 11:45:04 +02:00
andrew deryabin
41639c7610 Fixed MinTimeLoggingCursor.callproc() 2015-05-03 10:30:11 +01:00
Daniele Varrazzo
9d547469b8 Add register_default_jsonb() and register the type 2014-08-13 02:02:01 +01:00
Piotr Kasprzyk
31b6ec63f8 Fix multiple misspellings 2013-04-26 09:59:40 +01:00
Daniele Varrazzo
711c092a79 The UUID adapter returns bytes instead of str in Python 3
Also added __conform__ method to the adapter.
2013-04-07 22:19:04 +01:00
Daniele Varrazzo
2b554937f2 Dropped __all__ from modules
They were only used to generate docs with Epydoc, now largely forgotten.

Imports in extras cleaned up to expose the API only.
2013-04-07 02:59:30 +01:00
Daniele Varrazzo
6df6e6adfe Fixed pickling of DictRow objects too 2012-12-11 01:10:45 +00:00
Daniele Varrazzo
99bedd1bb2 Fixed pickling of RealDictRow objects 2012-12-10 23:54:25 +00:00
Daniele Varrazzo
9a031db8b9 Fixed empty strings handling in composite caster
Closes ticket #141.
2012-12-03 14:19:09 +00:00
Daniele Varrazzo
9f9da182f1 Using super() in the connection/cursor subclasses
This opens to collaborative subclassing (e.g. you may want to have a
logging namedtuple cursor...)
2012-09-28 02:51:58 +01:00
Daniele Varrazzo
4244d5953a Merge branch 'range-type' into devel 2012-09-27 00:48:05 +01:00
Daniele Varrazzo
dda24f082f Merge branch 'json' into devel 2012-09-27 00:41:04 +01:00
Daniele Varrazzo
33043cd038 Merge branch 'composite-custom' into devel 2012-09-27 00:38:00 +01:00
Daniele Varrazzo
94c6353d55 NumberRange renamed to NumericRange
I was avoiding Numeric to avoid conflicting with the 'numeric'
Postgres type, which is an alias for 'decimal'. But now that there
is a single numeric range I can use the preferred name
2012-09-23 21:11:06 +01:00
Daniele Varrazzo
45cbcc0713 Dropped Range classes for specific numeric types 2012-09-23 21:08:18 +01:00
Daniele Varrazzo
5e7c1d0b51 Added first implementation of Range type, adapter, typecaster 2012-09-23 21:03:36 +01:00
Daniele Varrazzo
9949e04c70 Added schema attribute to CompositeCaster 2012-09-22 15:10:40 +01:00
Daniele Varrazzo
59151886a0 Info about hstore versions history moved from code to docs 2012-09-22 02:10:58 +01:00
Daniele Varrazzo
26cfdc1234 Info about versions history moved from code to docs 2012-09-22 02:08:21 +01:00
Daniele Varrazzo
fa9393b587 Added documentation about CompositeCaster subclassing 2012-09-22 02:01:04 +01:00
Daniele Varrazzo
1b2c2c34b6 Make CompositeCaster easier to subclass 2012-09-22 01:46:53 +01:00
Daniele Varrazzo
526e270934 Use namedtuple._make in NamedTupleCursor and CompositeCaster
Makes things more natural as _make has the same signature of the tuple (see
_ctor in CompositeCaster) and is probably more efficient with less
intermediate sequences to build.
2012-09-20 16:27:50 +01:00
Daniele Varrazzo
d963b478e2 Added register_default_json() function
Register a typecaster for PostgreSQL 9.2 json.
2012-09-19 15:49:00 +01:00
Daniele Varrazzo
024f0dbada Added json typecaster 2012-09-19 04:26:35 +01:00
Daniele Varrazzo
b8e7f02256 Added Json adapter 2012-09-19 04:12:20 +01:00
Daniele Varrazzo
21d323d2c8 Fixed register_hstore and register_composite with non-dbapi objects
Closed ticket #114.
2012-08-14 23:26:17 +01:00
Daniele Varrazzo
ba1fe6fff6 Fixed superclass methods call.
Methods execute() and callproc() in DictCursor and RealDictCursor should
call DictCursorBase methods, not _cursor's ones.

Reported by Alexey Luchko on the ML.
2012-05-08 15:48:07 +01:00
Daniele Varrazzo
c86ca7687f Fixed cursor() arguments propagation to other connection classes 2012-04-11 17:59:16 +01:00
Corry Haines
095cce5605 Allow user to override connection factory cursors
Prior to this change, using a extras.connection_factory would not allow
any other cursor to be used on that connection. It was set in stone.

This change allows all cursor options to pass through and override the
connection factory behaviors. This allows a connection_factory to be
dropped into existing code with no disruption.

This change also standardizes the extras.connection_factories to have
the same behavior and all pass through *args and **kwargs.
2012-04-11 17:36:04 +01:00
Marti Raudsepp
b97599166e Update all links to PostgreSQL docs to the current version.
I also checked all links and anchors to make sure they're still valid.
2012-02-28 18:28:07 +02:00
Daniele Varrazzo
0c337a2029 Added support for inet array 2012-02-23 23:56:55 +00:00
Daniele Varrazzo
36b6c80ed1 register_uuid takes more iterables types as oids argument
Also added docs for the function parameters.
2012-02-23 23:51:28 +00:00
Daniele Varrazzo
b8597dc1d3 Fixed NamedTupleCursor rownumber during iteration.
The correction is similar to the other one for the other subclasses.

Also added tests for rowcount and rownumber during different fetch styles.
Just in case.
2012-02-23 22:58:58 +00:00
Daniele Varrazzo
ebec522a07 Fixed rownumber for cursor subclasses during iterations
Regression introduced to fix ticket #80. Don't use fetchmany to get the
chunks of values. I did it that way because I was ending up into infinite
recursion calling __iter__ from __iter__: the solution has been the
"while 1: yield next()" idiom.
2012-02-23 22:55:13 +00:00
Daniele Varrazzo
dca6cffd6e Dropped custom array parsing for UUID[]
Use the C generic array parsing exposed by new_array_type().
2012-02-23 14:41:55 +00:00
Daniele Varrazzo
f782470d71 Parens don't need escaping in regexp char classes 2012-02-23 14:41:51 +00:00
Daniele Varrazzo
1332d4a0d8 Fixed never raised exception in composite parsing 2012-02-23 14:41:46 +00:00
Daniele Varrazzo
2cf35b69de 'register_composite()' also works with tables
Skip dropped and hidden columns when inspecting the schema.
2011-12-15 20:11:17 +00:00
Daniele Varrazzo
a4485022b5 Use 'autocommit' to check if to rollback after extra types registration
isolation_level currently requires an extra query, autocommit doesn't.
2011-12-15 19:56:52 +00:00
Daniele Varrazzo
bb8e1e9455 Fixed error in schema mismatch in composite caster 2011-12-15 19:56:52 +00:00
Daniele Varrazzo
8473209d24 Named DictCursor/RealDictCursor honour itersize
Closes ticket #80.
2011-12-11 22:06:15 +00:00
Daniele Varrazzo
8963b8adcb Added support for arrays of composite types 2011-09-22 19:57:42 +02:00
Daniele Varrazzo
2f9ceeac64 Added support for arrays of hstores 2011-09-22 19:56:58 +02:00
Daniele Varrazzo
d67d50b434 Fixed interaction between RealDictCursor and named cursors
Closes ticket #67.
2011-09-12 02:20:53 +01:00
Daniele Varrazzo
9870ca4dce Fixed NamedTupleCursor.executemany() (ticket #65) 2011-08-09 11:44:30 +01:00
Marko Kreen
cb1d163f4f lazy import for uuid module
Attached patch moves uuid import from inside try-except
to register_uuid function.  Reason: uuid module import is *very*
heavy.  It goes into OS searching for various .dll/.so libraries,
lauches 'ldconfig' and so on...

With this patch, 200x python -c 'import psycopg2.extras'
goes from 22s to 7s.  (plain 'import psycopg2' is 6s)

--
marko
2011-06-28 17:28:43 +02:00
Daniele Varrazzo
c61ec094a3 Don't fetch all the records iterating a NamedTuple cursor on a named cursor 2011-04-26 19:26:19 +01:00
Daniele Varrazzo
ffa7a62b93 Fixed interaction between NamedTuple and named cursor
Build the nametuple after fetching the first resutl, or else
cursor.description will be empty.
2011-04-26 19:18:39 +01:00
Daniele Varrazzo
80891e64b3 Dropped unused import 2011-04-26 19:16:10 +01:00
Daniele Varrazzo
9e00196165 Fixed use of the new return value of HstoreAdapter.get_oids() 2011-02-25 01:37:02 +00:00
Daniele Varrazzo
5211e1474b Don't limit the hstore search to the public schema only
Looks like there is a case for installing hstore somewhere else (see
ticket #45). And after all the typecaster can be registered on a list of
OIDs, so let's grab them all.
2011-02-25 00:19:49 +00:00
Daniele Varrazzo
143dc2e911 Added oid parameter to register_hstore()
The parameter is mostly useful with async connections that would need a
different protocol to be queried.

Issue reported by Jan "the Asynchronous".
2011-02-21 01:29:53 +00:00
Daniele Varrazzo
556b4d461e Documentation cleanup
Added several links to the Python documentation using the 'intersphinx'
extension.
2011-02-19 16:16:28 +00:00
Daniele Varrazzo
7a058403ca Fixed mapping for composite types defined in a schema 2011-02-09 02:22:03 +01:00
Daniele Varrazzo
8ac5f0070a Fields order enforced in composite types adapter 2011-02-09 02:21:55 +01:00
Daniele Varrazzo
80bd6e2794 Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	psycopg/connection_type.c
	tests/test_connection.py
	tests/types_basic.py
2011-01-03 21:43:02 +01:00
Daniele Varrazzo
68305a0eb6 Fixed TYPE adaptation to basic tuples
Tuples and namedtuples have different constructors.
2011-01-03 19:27:26 +01:00
Daniele Varrazzo
929d62053a Merge branch 'python2' into python3
Conflicts:
	NEWS-2.3
	setup.py
2011-01-02 03:28:00 +01:00
Daniele Varrazzo
7ac0bdd661 Added PostgreSQL composite types typecaster to Python tuples. 2011-01-02 00:34:13 +01:00
Daniele Varrazzo
2fa9117835 Inet adapter compatible with Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
c176de4bf8 Hstore adapter compatible with Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
e18f1c63ea Deal with slices passed to __*item__ in Python 3. 2010-12-23 03:28:19 +01:00
Daniele Varrazzo
31093a7a58 Some light cleanup for Py3 conversion.
Either flagged as warning by python2.6 -3 or converted by 2to3.
2010-12-21 04:02:13 +00:00
Daniele Varrazzo
0ad7483a2b DictRow items can be updated. Patch by Alex Aster. 2010-12-01 13:17:12 +00:00
Daniele Varrazzo
94348bfb78 hstore registration doesn't fail if typarray column not available. 2010-11-19 03:51:53 +00:00
Daniele Varrazzo
3cae0f3f5d NamedTupleCursor doesn't change exception when fetching with no result. 2010-11-11 10:39:42 +00:00