Update upstream source from tag 'upstream/0.16.0'
Update to upstream version '0.16.0'
with Debian dir b12047e2ecad0de1e638923439b91f10cd4e375e
Piotr Ożarowski
4 years ago
0 | 0 | CHANGES |
1 | 1 | ------- |
2 | 2 | |
3 | 0.16.0 (2019-01-25) | |
4 | ^^^^^^^^^^^^^^^^^^^ | |
5 | ||
6 | * Fix select priority name (#525) | |
7 | ||
8 | * Rename `psycopg2` to `psycopg2-binary` to fix deprecation warning (#507) | |
9 | ||
10 | * Fix #189 hstore when using ReadDictCursor (#512) | |
11 | ||
12 | * close cannot be used while an asynchronous query is underway (#452) | |
13 | ||
14 | * sqlalchemy adapter trx begin allow transaction_mode (#498) | |
15 | ||
16 | ||
3 | 17 | 0.15.0 (2018-08-14) |
4 | 18 | ^^^^^^^^^^^^^^^^^^^ |
5 | 19 |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: aiopg |
2 | Version: 0.15.0 | |
2 | Version: 0.16.0 | |
3 | 3 | Summary: Postgres integration with asyncio. |
4 | 4 | Home-page: https://aiopg.readthedocs.io |
5 | 5 | Author: Andrew Svetlov |
96 | 96 | |
97 | 97 | CHANGES |
98 | 98 | ------- |
99 | ||
100 | 0.16.0 (2019-01-25) | |
101 | ^^^^^^^^^^^^^^^^^^^ | |
102 | ||
103 | * Fix select priority name (#525) | |
104 | ||
105 | * Rename `psycopg2` to `psycopg2-binary` to fix deprecation warning (#507) | |
106 | ||
107 | * Fix #189 hstore when using ReadDictCursor (#512) | |
108 | ||
109 | * close cannot be used while an asynchronous query is underway (#452) | |
110 | ||
111 | * sqlalchemy adapter trx begin allow transaction_mode (#498) | |
112 | ||
99 | 113 | |
100 | 114 | 0.15.0 (2018-08-14) |
101 | 115 | ^^^^^^^^^^^^^^^^^^^ |
10 | 10 | 'version', 'version_info', 'DEFAULT_TIMEOUT', 'IsolationLevel', |
11 | 11 | 'Transaction') |
12 | 12 | |
13 | __version__ = '0.15.0' | |
13 | __version__ = '0.16.0' | |
14 | 14 | |
15 | 15 | version = __version__ + ' , Python ' + sys.version |
16 | 16 |
38 | 38 | """) |
39 | 39 | rv0, rv1 = [], [] |
40 | 40 | for oids in (yield from cur.fetchall()): |
41 | rv0.append(oids[0]) | |
42 | rv1.append(oids[1]) | |
41 | if isinstance(oids, dict): | |
42 | rv0.append(oids['oid']) | |
43 | rv1.append(oids['typarray']) | |
44 | else: | |
45 | rv0.append(oids[0]) | |
46 | rv1.append(oids[1]) | |
43 | 47 | |
44 | 48 | cur.close() |
45 | 49 | return tuple(rv0), tuple(rv1) |
116 | 120 | self._cancelling = False |
117 | 121 | self._cancellation_waiter = None |
118 | 122 | self._echo = echo |
123 | self._conn_cursor = None | |
119 | 124 | self._notifies = asyncio.Queue(loop=loop) |
120 | 125 | self._weakref = weakref.ref(self) |
121 | 126 | self._loop.add_reader(self._fileno, self._ready, self._weakref) |
127 | ||
122 | 128 | if loop.get_debug(): |
123 | 129 | self._source_traceback = traceback.extract_stack(sys._getframe(1)) |
124 | 130 | |
263 | 269 | *name*, *scrollable* and *withhold* parameters are not supported by |
264 | 270 | psycopg in asynchronous mode. |
265 | 271 | |
272 | NOTE: as of [TODO] any previously created created cursor from this | |
273 | connection will be closed | |
266 | 274 | """ |
275 | self.close_cursor() | |
276 | ||
267 | 277 | self._last_usage = self._loop.time() |
268 | 278 | coro = self._cursor(name=name, cursor_factory=cursor_factory, |
269 | 279 | scrollable=scrollable, withhold=withhold, |
270 | 280 | timeout=timeout) |
271 | 281 | return _ContextManager(coro) |
272 | 282 | |
283 | def cursor_created(self, cursor): | |
284 | if self._conn_cursor and not self._conn_cursor.closed: | |
285 | raise Exception("You can only have one cursor per connection") | |
286 | ||
287 | self._conn_cursor = cursor | |
288 | ||
289 | def cursor_closed(self, cursor): | |
290 | if cursor != self._conn_cursor: | |
291 | raise Exception("You can only have one cursor per connection") | |
292 | ||
293 | self._conn_cursor = None | |
294 | ||
273 | 295 | @asyncio.coroutine |
274 | 296 | def _cursor(self, name=None, cursor_factory=None, |
275 | 297 | scrollable=None, withhold=False, timeout=None): |
280 | 302 | cursor_factory=cursor_factory, |
281 | 303 | scrollable=scrollable, |
282 | 304 | withhold=withhold) |
283 | return Cursor(self, impl, timeout, self._echo) | |
305 | cursor = Cursor(self, impl, timeout, self._echo) | |
306 | return cursor | |
284 | 307 | |
285 | 308 | @asyncio.coroutine |
286 | 309 | def _cursor_impl(self, name=None, cursor_factory=None, |
302 | 325 | if self._writing: |
303 | 326 | self._writing = False |
304 | 327 | self._loop.remove_writer(self._fileno) |
328 | ||
329 | self.close_cursor() | |
305 | 330 | self._conn.close() |
331 | ||
306 | 332 | if self._waiter is not None and not self._waiter.done(): |
307 | 333 | self._waiter.set_exception( |
308 | 334 | psycopg2.OperationalError("Connection closed")) |
312 | 338 | ret = create_future(self._loop) |
313 | 339 | ret.set_result(None) |
314 | 340 | return ret |
341 | ||
342 | def close_cursor(self): | |
343 | if self._conn_cursor: | |
344 | self._conn_cursor.close() | |
315 | 345 | |
316 | 346 | @property |
317 | 347 | def closed(self): |
14 | 14 | self._timeout = timeout |
15 | 15 | self._echo = echo |
16 | 16 | self._transaction = Transaction(self, IsolationLevel.repeatable_read) |
17 | ||
18 | conn.cursor_created(self) | |
17 | 19 | |
18 | 20 | @property |
19 | 21 | def echo(self): |
47 | 49 | |
48 | 50 | def close(self): |
49 | 51 | """Close the cursor now.""" |
50 | self._impl.close() | |
52 | if not self.closed: | |
53 | self._impl.close() | |
54 | self._conn.cursor_closed(self) | |
51 | 55 | |
52 | 56 | @property |
53 | 57 | def closed(self): |
256 | 256 | if self._closing: |
257 | 257 | conn.close() |
258 | 258 | else: |
259 | conn.close_cursor() # there may be weak-refs to these cursors | |
259 | 260 | self._free.append(conn) |
260 | 261 | fut = ensure_future(self._wakeup(), loop=self._loop) |
261 | 262 | return fut |
133 | 133 | def connection(self): |
134 | 134 | return self._connection |
135 | 135 | |
136 | def begin(self): | |
136 | def begin(self, isolation_level=None, readonly=False, deferrable=False): | |
137 | 137 | """Begin a transaction and return a transaction handle. |
138 | ||
139 | isolation_level - The isolation level of the transaction, | |
140 | should be one of 'SERIALIZABLE', 'REPEATABLE READ', 'READ COMMITTED', | |
141 | 'READ UNCOMMITTED', default (None) is 'READ COMMITTED' | |
142 | ||
143 | readonly - The transaction is read only | |
144 | ||
145 | deferrable - The transaction may block when acquiring data before | |
146 | running without overhead of SERLIALIZABLE, has no effect unless | |
147 | transaction is both SERIALIZABLE and readonly | |
138 | 148 | |
139 | 149 | The returned object is an instance of Transaction. This |
140 | 150 | object represents the "scope" of the transaction, which |
160 | 170 | .begin_twophase - use a two phase/XA transaction |
161 | 171 | |
162 | 172 | """ |
163 | coro = self._begin() | |
173 | coro = self._begin(isolation_level, readonly, deferrable) | |
164 | 174 | return _TransactionContextManager(coro) |
165 | 175 | |
166 | 176 | @asyncio.coroutine |
167 | def _begin(self): | |
177 | def _begin(self, isolation_level, readonly, deferrable): | |
168 | 178 | if self._transaction is None: |
169 | 179 | self._transaction = RootTransaction(self) |
170 | yield from self._begin_impl() | |
180 | yield from self._begin_impl(isolation_level, readonly, deferrable) | |
171 | 181 | return self._transaction |
172 | 182 | else: |
173 | 183 | return Transaction(self, self._transaction) |
174 | 184 | |
175 | 185 | @asyncio.coroutine |
176 | def _begin_impl(self): | |
177 | cur = yield from self._connection.cursor() | |
178 | try: | |
179 | yield from cur.execute('BEGIN') | |
186 | def _begin_impl(self, isolation_level, readonly, deferrable): | |
187 | stmt = 'BEGIN' | |
188 | if isolation_level is not None: | |
189 | stmt += ' ISOLATION LEVEL ' + isolation_level | |
190 | if readonly: | |
191 | stmt += ' READ ONLY' | |
192 | if deferrable: | |
193 | stmt += ' DEFERRABLE' | |
194 | ||
195 | cur = yield from self._connection.cursor() | |
196 | try: | |
197 | yield from cur.execute(stmt) | |
180 | 198 | finally: |
181 | 199 | cur.close() |
182 | 200 | |
216 | 234 | def _begin_nested(self): |
217 | 235 | if self._transaction is None: |
218 | 236 | self._transaction = RootTransaction(self) |
219 | yield from self._begin_impl() | |
237 | yield from self._begin_impl(None, False, False) | |
220 | 238 | else: |
221 | 239 | self._transaction = NestedTransaction(self, self._transaction) |
222 | 240 | self._transaction._savepoint = yield from self._savepoint_impl() |
88 | 88 | def __init__(self, result_proxy, metadata): |
89 | 89 | self._processors = processors = [] |
90 | 90 | |
91 | result_map = {} | |
92 | if result_proxy._result_map: | |
93 | result_map = {elem[0]: elem[3] for elem in | |
94 | result_proxy._result_map} | |
91 | map_type, map_column_name = self.result_map(result_proxy._result_map) | |
95 | 92 | |
96 | 93 | # We do not strictly need to store the processor in the key mapping, |
97 | 94 | # though it is faster in the Python version (probably because of the |
123 | 120 | # colname = dialect.normalize_name(colname) |
124 | 121 | |
125 | 122 | name, obj, type_ = ( |
126 | colname, | |
123 | map_column_name.get(colname, colname), | |
127 | 124 | None, |
128 | result_map.get( | |
129 | colname, | |
130 | typemap.get(coltype, sqltypes.NULLTYPE)) | |
125 | map_type.get(colname, typemap.get(coltype, sqltypes.NULLTYPE)) | |
131 | 126 | ) |
132 | 127 | |
133 | 128 | processor = type_._cached_result_processor(dialect, coltype) |
149 | 144 | # unambiguous. |
150 | 145 | primary_keymap[name] = rec = (None, obj, None) |
151 | 146 | |
152 | self.keys.append(colname) | |
147 | self.keys.append(name) | |
153 | 148 | if obj: |
154 | 149 | for o in obj: |
155 | 150 | keymap[o] = rec |
161 | 156 | # overwrite keymap values with those of the |
162 | 157 | # high precedence keymap. |
163 | 158 | keymap.update(primary_keymap) |
159 | ||
160 | def result_map(self, data_map): | |
161 | data_map = data_map or {} | |
162 | map_type = {} | |
163 | map_column_name = {} | |
164 | for elem in data_map: | |
165 | name = elem[0] | |
166 | priority_name = getattr(elem[2][0], 'key', name) | |
167 | map_type[name] = elem[3] # type column | |
168 | map_column_name[name] = priority_name | |
169 | ||
170 | return map_type, map_column_name | |
164 | 171 | |
165 | 172 | def _key_fallback(self, key, raiseerr=True): |
166 | 173 | map = self._keymap |
174 | 181 | elif isinstance(key, expression.ColumnElement): |
175 | 182 | if (key._label and key._label in map): |
176 | 183 | result = map[key._label] |
177 | elif (hasattr(key, 'name') and key.name in map): | |
184 | elif (hasattr(key, 'key') and key.key in map): | |
178 | 185 | # match is only on name. |
179 | result = map[key.name] | |
186 | result = map[key.key] | |
180 | 187 | # search extra hard to make sure this |
181 | 188 | # isn't a column/label name overlap. |
182 | 189 | # this check isn't currently available if the row |
0 | 0 | Metadata-Version: 2.1 |
1 | 1 | Name: aiopg |
2 | Version: 0.15.0 | |
2 | Version: 0.16.0 | |
3 | 3 | Summary: Postgres integration with asyncio. |
4 | 4 | Home-page: https://aiopg.readthedocs.io |
5 | 5 | Author: Andrew Svetlov |
96 | 96 | |
97 | 97 | CHANGES |
98 | 98 | ------- |
99 | ||
100 | 0.16.0 (2019-01-25) | |
101 | ^^^^^^^^^^^^^^^^^^^ | |
102 | ||
103 | * Fix select priority name (#525) | |
104 | ||
105 | * Rename `psycopg2` to `psycopg2-binary` to fix deprecation warning (#507) | |
106 | ||
107 | * Fix #189 hstore when using ReadDictCursor (#512) | |
108 | ||
109 | * close cannot be used while an asynchronous query is underway (#452) | |
110 | ||
111 | * sqlalchemy adapter trx begin allow transaction_mode (#498) | |
112 | ||
99 | 113 | |
100 | 114 | 0.15.0 (2018-08-14) |
101 | 115 | ^^^^^^^^^^^^^^^^^^^ |
0 | psycopg2>=2.7.0 | |
0 | psycopg2-binary>=2.7.0 | |
1 | 1 | |
2 | 2 | [sa] |
3 | sqlalchemy>=1.1 | |
3 | sqlalchemy[postgresql_psycopg2binary]>=1.1 |
3 | 3 | from setuptools import setup |
4 | 4 | |
5 | 5 | |
6 | install_requires = ['psycopg2>=2.7.0'] | |
6 | install_requires = ['psycopg2-binary>=2.7.0'] | |
7 | extras_require = {'sa': ['sqlalchemy[postgresql_psycopg2binary]>=1.1']} | |
7 | 8 | |
8 | 9 | PY_VER = sys.version_info |
9 | 10 | |
13 | 14 | |
14 | 15 | def read(f): |
15 | 16 | return open(os.path.join(os.path.dirname(__file__), f)).read().strip() |
16 | ||
17 | ||
18 | extras_require = {'sa': ['sqlalchemy>=1.1'], } | |
19 | 17 | |
20 | 18 | |
21 | 19 | def read_version(): |