risclog.sqlalchemy 7.2__tar.gz → 8.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/CHANGES.rst +6 -0
  2. risclog.sqlalchemy-8.0/PKG-INFO +434 -0
  3. risclog.sqlalchemy-8.0/requirements.txt +3 -0
  4. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/setup.py +5 -2
  5. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/db.py +15 -11
  6. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/model.py +1 -1
  7. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/test_cache.py +3 -1
  8. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/test_db.py +5 -3
  9. risclog.sqlalchemy-8.0/src/risclog.sqlalchemy.egg-info/PKG-INFO +434 -0
  10. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog.sqlalchemy.egg-info/requires.txt +4 -1
  11. risclog.sqlalchemy-7.2/PKG-INFO +0 -441
  12. risclog.sqlalchemy-7.2/requirements.txt +0 -10
  13. risclog.sqlalchemy-7.2/src/risclog.sqlalchemy.egg-info/PKG-INFO +0 -441
  14. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/COPYRIGHT.rst +0 -0
  15. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/HACKING.rst +0 -0
  16. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/LICENSE.txt +0 -0
  17. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/README.rst +0 -0
  18. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/doc/about.txt +0 -0
  19. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/doc/api.txt +0 -0
  20. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/doc/changes.txt +0 -0
  21. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/doc/conf.py +0 -0
  22. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/doc/index.txt +0 -0
  23. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/pyproject.toml +0 -0
  24. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/setup.cfg +0 -0
  25. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/__init__.py +0 -0
  26. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/__init__.py +0 -0
  27. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/cache.py +0 -0
  28. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/fixtures.py +0 -0
  29. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/functions.py +0 -0
  30. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/interfaces.py +0 -0
  31. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/serializer.py +0 -0
  32. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/testing.py +0 -0
  33. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/testlayer.py +0 -0
  34. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/__init__.py +0 -0
  35. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/conftest.py +0 -0
  36. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/fixtures/alembic/env.py +0 -0
  37. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/fixtures/alembic/script.py.mako +0 -0
  38. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/fixtures/alembic/versions/3f735078d5a8_foo.py +0 -0
  39. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/test_fixtures.py +0 -0
  40. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/test_model.py +0 -0
  41. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog/sqlalchemy/tests/test_serializer.py +0 -0
  42. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog.sqlalchemy.egg-info/SOURCES.txt +0 -0
  43. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog.sqlalchemy.egg-info/dependency_links.txt +0 -0
  44. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog.sqlalchemy.egg-info/namespace_packages.txt +0 -0
  45. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog.sqlalchemy.egg-info/not-zip-safe +0 -0
  46. {risclog.sqlalchemy-7.2 → risclog.sqlalchemy-8.0}/src/risclog.sqlalchemy.egg-info/top_level.txt +0 -0
@@ -2,6 +2,12 @@
2
2
  Change log for risclog.sqlalchemy
3
3
  =================================
4
4
 
5
+ 8.0 (2025-02-12)
6
+ ================
7
+
8
+ - Add compatability to sqlalchemy 2. Break with compatability to sqlalchemy < 1.4.
9
+
10
+
5
11
  7.2 (2024-04-19)
6
12
  ================
7
13
 
@@ -0,0 +1,434 @@
1
+ Metadata-Version: 2.1
2
+ Name: risclog.sqlalchemy
3
+ Version: 8.0
4
+ Summary: Encapsulate sqlalchemy modelling infrastructure.
5
+ Home-page: https://github.com/gocept/risclog.sqlalchemy
6
+ Author: gocept <mail@gocept.com>
7
+ Author-email: mail@gocept.com
8
+ License: ZPL 2.1
9
+ Description: ==================
10
+ risclog.sqlalchemy
11
+ ==================
12
+
13
+ risclog.sqlalchemy encapsulates `sqlalchemy`_ modelling infrastructure. It
14
+ eases the setup of (multi-)database environments and the usage of sqlalchemy
15
+ models by providing often used functionality on special classes.
16
+
17
+ This package is compatible with Python version 3.7 up to 3.11.
18
+
19
+ .. _`sqlalchemy`: http://www.sqlalchemy.org
20
+
21
+
22
+ =============================
23
+ Developing risclog.sqlalchemy
24
+ =============================
25
+
26
+ :Author:
27
+ `gocept <http://gocept.com/>`_ <mail@gocept.com>
28
+
29
+ :Outdated Online documentation:
30
+ https://pythonhosted.org/risclog.sqlalchemy/
31
+
32
+ :PyPI page:
33
+ https://pypi.org/project/risclog.sqlalchemy/
34
+
35
+ :Issue tracker:
36
+ https://github.com/gocept/risclog.sqlalchemy/issues/
37
+
38
+ :Source code:
39
+ https://github.com/gocept/risclog.sqlalchemy
40
+
41
+ :Current change log:
42
+ https://github.com/gocept/risclog.sqlalchemy/blob/master/CHANGES.rst
43
+
44
+
45
+ Running tests
46
+ =============
47
+
48
+ Simply run `./pytest` in the root of the repository.
49
+
50
+
51
+ Documentation
52
+ =============
53
+
54
+ In order to build the Sphinx documentation, run the following command with a
55
+ python, where ``sphinx`` is installed::
56
+
57
+ $ python setup.py build_sphinx
58
+
59
+
60
+ In order to upload the Sphinx documentation, run the following command with a
61
+ python, where ``sphinx-pypi-upload`` is installed::
62
+
63
+ $ python setup.py upload_sphinx
64
+
65
+
66
+ =================================
67
+ Change log for risclog.sqlalchemy
68
+ =================================
69
+
70
+ 8.0 (2025-02-12)
71
+ ================
72
+
73
+ - Add compatability to sqlalchemy 2. Break with compatability to sqlalchemy < 1.4.
74
+
75
+
76
+ 7.2 (2024-04-19)
77
+ ================
78
+
79
+ - Add json encoder for `datetime.time` objects.
80
+
81
+
82
+ 7.1 (2024-03-22)
83
+ ================
84
+
85
+ - Fix `sqlalchemy` 1.3 compatibility in `Database.empty()`.
86
+
87
+
88
+ 7.0 (2024-03-21)
89
+ ================
90
+
91
+ - Introduce new `RoutingSession` method `execute_with_bind()` to execute
92
+ statements with a specific bind.
93
+ - `RoutingSession.using_bind()` is now deprecated and kept for backward
94
+ compatibility.
95
+ Instead of a new session instance, it now returns a shim that maps a
96
+ minimal subset of session methods to the original session instance.
97
+ This change was necessary because the previous implementation of creating
98
+ a new session instance and copying all the original session's state
99
+ proved unstable when used with SQLAlchemy 1.4. (One reason being the new
100
+ autobegin feature of sessions changing interactions with `zope.sqlalchemy`.)
101
+
102
+
103
+ 6.1 (2024-03-12)
104
+ ================
105
+
106
+ - Add json encoder for `uuid.UUID` objects.
107
+
108
+ - Add `risclog.sqlalchemy.interfaces.Deleted` event which is fired when an
109
+ object is deleted from the database.
110
+
111
+
112
+ 6.0 (2023-09-26)
113
+ ================
114
+
115
+ - Introduce `ModelCache` that reduces the number of DB requests when dealing
116
+ with huge amounts of sqlalchemy models.
117
+
118
+ - Allow specifying `keep_session` and `expire_on_commit`.
119
+
120
+ - Drop support for Python 3.6.
121
+
122
+ - Drop support for SQLAlchemy 1.0 and 1.1.
123
+
124
+ - Add support for Python 3.10 and 3.11.
125
+
126
+ - Restrict supported SQLALchemy to < 2.
127
+
128
+
129
+ 5.1 (2021-04-28)
130
+ ================
131
+
132
+ Features
133
+ --------
134
+
135
+ - Ensure compatibility with ``SQLAlchemy >= 1.4``.
136
+
137
+ Other changes
138
+ -------------
139
+
140
+ - Use github actions as CI.
141
+
142
+
143
+ 5.0 (2020-11-03)
144
+ ================
145
+
146
+ Backward incompatible changes
147
+ -----------------------------
148
+
149
+ - Drop support for Python 2.
150
+
151
+ - Drop the ``python2`` extra in ``setup.py``.
152
+
153
+ Features
154
+ --------
155
+
156
+ - No longer constraint to ``zope.component < 4.4.1`` (introduced in 3.0).
157
+
158
+
159
+ 4.0 (2020-02-17)
160
+ ================
161
+
162
+ Backward incompatible changes
163
+ -----------------------------
164
+
165
+ - Add support for ``zope.sqlalchemy >= 1.3`` by requiring at least this version.
166
+ (Older versions only supported ``zope.sqlalchemy <= 1.2``.)
167
+
168
+ - Drop support for PyPy, PyPy3, Python 3.4 and 3.5.
169
+
170
+ Other changes
171
+ -------------
172
+
173
+ - Add support for Python 3.7, 3.8, 3.9a3.
174
+
175
+ - Migrate to Github.
176
+
177
+
178
+ 3.0 (2018-01-16)
179
+ ================
180
+
181
+ - Drop support for Python 3.3.
182
+
183
+ - Reintroduce `RoutingSession.using_bind` as it is needed for executing queries
184
+ in multi database environments. It was removed in version `2.0`.
185
+
186
+ - Pin to ``zope.component < 4.4.1`` for now as we are using a private variable
187
+ from this package which has been removed lately.
188
+
189
+
190
+ 2.3 (2017-04-06)
191
+ ================
192
+
193
+ - Add the fixture ``.fixtures.database__selenium_testing`` to switch SQLAlchemy
194
+ session handling to into the same way the live server does it. Using this
195
+ fixture leads to `DetachedInstanceError` exceptions when using a database
196
+ object after the commit. It has to be fetched again from the database.
197
+
198
+ - Omit files from sdist which are related to buildout, testing or mercurial.
199
+
200
+ 2.2 (2017-01-12)
201
+ ================
202
+
203
+ - Support Python 3.6 and PyPy3.
204
+
205
+ - Fix `setup.py` to no longer use absolute paths.
206
+
207
+
208
+ 2.1 (2016-01-25)
209
+ ================
210
+
211
+ - Add compatibility to `pypy`.
212
+
213
+ Also removed explicit dependency to `psycopg2` as it's a PostgreSQL specific
214
+ dependency and not compatible with pypy. You will need `psycopg2cffi` in
215
+ order to run `risclog.sqlalchemy` with `pypy`.
216
+
217
+
218
+ 2.0 (2015-12-18)
219
+ ================
220
+
221
+ - Removed ``RoutingSession.using_bind``, require SQLAlchemy >= 1.0. (#13968)
222
+
223
+ - Updated API calls to alembic, require alembic >= 0.7. (#13968)
224
+
225
+ - Added documentation. (#13952)
226
+
227
+
228
+ 1.8 (2015-09-29)
229
+ ================
230
+
231
+ - Officially supporting Python 3.3 up to 3.5.
232
+
233
+ - Set maximum supported version numbers of ``alembic`` and ``SQLALchemy``
234
+ in `setup.py`
235
+
236
+
237
+ 1.7.1 (2014-10-15)
238
+ ==================
239
+
240
+ - Fix bug in testing mode detection so it works with sqlite, too.
241
+
242
+
243
+ 1.7 (2014-07-29)
244
+ ================
245
+
246
+ - Have ``.model.Object.create`` use the ``**kw`` constructor instead of
247
+ performing setattr itself.
248
+
249
+ - Made commit in db.empty optional.
250
+
251
+
252
+ 1.6 (2014-06-23)
253
+ ================
254
+
255
+ - Make test setup/teardown a bit more independent from the IDatabase utility.
256
+ - Made pyramid dependent code optional, because it is an optional requirement.
257
+
258
+
259
+ 1.5.1 (2014-03-31)
260
+ ==================
261
+
262
+ - Moved the project to bitbucket.org and prepared for public release.
263
+
264
+
265
+ 1.5 (2014-03-06)
266
+ ================
267
+
268
+ - Adjust test dependency for external projects, so pyramid is not required.
269
+ (#1458)
270
+
271
+
272
+ 1.4 (2014-01-27)
273
+ ================
274
+
275
+ - Do not truncate `spatial_ref_sys` when emptying entire database. (#13144)
276
+
277
+
278
+ 1.3 (2013-12-18)
279
+ ================
280
+
281
+ - Do not truncate `alembic_versions` when emptying entire database (using
282
+ `db.empty(engine)`)
283
+
284
+ - Fix create_defaults, so it can be used with multiple engines. (#1172)
285
+
286
+
287
+ 1.2 (2013-12-13)
288
+ ================
289
+
290
+ - Fixed setup.py
291
+
292
+
293
+ 1.1 (2013-12-13)
294
+ ================
295
+
296
+ - Allow ``.db.Database.empty()`` to not restart sequences. (This can be
297
+ necassary if the user is not allowed to call `ALTER SEQUENCE`.)
298
+
299
+ - Create factory for JSON renderer, so it can be customized via arguments.
300
+ (#1037)
301
+
302
+
303
+ 1.0 (2013-12-11)
304
+ ================
305
+
306
+ - CAUTION: Backward incompatible changes to provide multiple database
307
+ support. You need to change:
308
+
309
+ * Use the ``pyramid`` extra to use the pyramid serializers and call
310
+ ``.serializer.patch()`` by yourself.
311
+
312
+ * Changes in `.model`:
313
+
314
+ + Use `.model.declarative_base(cls)` to register a class as SQLALchemy
315
+ ``declarative_base``.
316
+
317
+ + Use your own declarative_base as `.model.Object` has been dropped.
318
+
319
+ + Create your own `ReflectedObject` as `.model.ReflectedObject` has been
320
+ dropped.
321
+
322
+ * Changes in `.db.Database`:
323
+
324
+ + To get an instance use `.db.get_database(testing=<True|False>)`.
325
+
326
+ + To register a database with the utility use ``register_engine``.
327
+
328
+ + ``empty`` now expects to get the engine as first argument and allows to
329
+ cadcade via (``cascade=True``).
330
+
331
+
332
+ + ``_verify`` was removed, use ``_verify_engine`` now.
333
+
334
+ + ``setup_utility`` was removed, it is now done in ``__init__``.
335
+
336
+ + To access former ``engine``` attribute use ``get_engine``.
337
+
338
+ + ``close`` was renamed to ``drop_engine``.
339
+
340
+ + To create all tables for a database use ``create_all``.
341
+
342
+ * Changes in `.testing`:
343
+
344
+ + ``setUpDB`` lost its first argument as it was not used.
345
+
346
+ + ``setUp`` now expects a dict or ``None``, see its docstring.
347
+
348
+ - Provide a way to insert default values for new created models. (#1137)
349
+
350
+ - Added support for schema migrations with alembic.
351
+
352
+ - Dropped support for `Python 2.6`.
353
+
354
+ - Added convenience functions to create `py.test` database fixtures.
355
+
356
+ - Declared `pyramid` as test dependency so tests only need the ``test``
357
+ extra.
358
+
359
+ - Declared testing dependency on `plone.testing[test]` since we use
360
+ `plone.testing.zca` which imports that ``test`` extra's dependencies.
361
+
362
+
363
+ 0.6 (2013-06-27)
364
+ ================
365
+
366
+ - Added convenience methods on `.db.Database` for teardown in tests.
367
+
368
+ - Updated to Buildout 2.
369
+
370
+ - Using py.test as testrunner.
371
+
372
+ - Added Python 3.3 compatibility.
373
+
374
+
375
+ 0.5 (2013-06-14)
376
+ ================
377
+
378
+ - Add Database methods for setting up a database utility and emptying tables.
379
+
380
+ - Add testing layer that sets up a database utility (requires plone.testing).
381
+
382
+
383
+ 0.4 (2013-06-07)
384
+ ================
385
+
386
+ - Add helper to provide transparent json encoding of sqlalchemy mapped objects,
387
+ dates, datetimes and decimals. (#39)
388
+
389
+ - Add `create_defaults` class method on base model which can be used to create
390
+ test data into the database.
391
+
392
+
393
+ 0.3 (2013-06-04)
394
+ ================
395
+
396
+ - Repair db setup for reflected and unreflected objects.
397
+
398
+
399
+ 0.2 (2013-06-04)
400
+ ================
401
+
402
+ - Add unreflected Object model next to the reflected Object model.
403
+
404
+
405
+ 0.1 (2013-06-03)
406
+ ================
407
+
408
+ initial release
409
+
410
+ Keywords: sqlalchemy alembic model infrastructure utility
411
+ Platform: UNKNOWN
412
+ Classifier: Development Status :: 5 - Production/Stable
413
+ Classifier: Framework :: Pyramid
414
+ Classifier: Intended Audience :: Developers
415
+ Classifier: License :: OSI Approved
416
+ Classifier: License :: OSI Approved :: Zope Public License
417
+ Classifier: Natural Language :: English
418
+ Classifier: Operating System :: OS Independent
419
+ Classifier: Programming Language :: Python
420
+ Classifier: Programming Language :: Python :: 3
421
+ Classifier: Programming Language :: Python :: 3.7
422
+ Classifier: Programming Language :: Python :: 3.8
423
+ Classifier: Programming Language :: Python :: 3.9
424
+ Classifier: Programming Language :: Python :: 3.10
425
+ Classifier: Programming Language :: Python :: 3.11
426
+ Classifier: Programming Language :: Python :: Implementation
427
+ Classifier: Programming Language :: Python :: Implementation :: CPython
428
+ Classifier: Topic :: Database
429
+ Classifier: Topic :: Software Development :: Libraries
430
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
431
+ Requires-Python: >=3.7
432
+ Provides-Extra: test
433
+ Provides-Extra: self-test
434
+ Provides-Extra: pyramid
@@ -0,0 +1,3 @@
1
+ # Created by batou. Do not edit manually.
2
+ # appenv-python-preference: 3.10,3.11
3
+ -e .[test,self-test]
@@ -9,10 +9,10 @@ from setuptools import find_packages, setup
9
9
 
10
10
  setup(
11
11
  name='risclog.sqlalchemy',
12
- version='7.2',
12
+ version='8.0',
13
13
  python_requires='>=3.7',
14
14
  install_requires=[
15
- 'SQLAlchemy >= 1.0, < 2',
15
+ 'SQLAlchemy >= 1.4',
16
16
  'alembic >= 0.7',
17
17
  'pytz',
18
18
  'setuptools',
@@ -29,6 +29,9 @@ setup(
29
29
  'mock',
30
30
  'pyramid',
31
31
  'pytest',
32
+ 'psycopg2-binary',
33
+ 'greenlet',
34
+ 'pytest-cov',
32
35
  ],
33
36
  'pyramid': ['pyramid'],
34
37
  },
@@ -14,6 +14,7 @@ import zope.interface
14
14
  import zope.sqlalchemy
15
15
  from packaging.version import Version as parse_version
16
16
  from sqlalchemy import __version__ as sqlalchemy_version
17
+ from sqlalchemy import text
17
18
 
18
19
  # Mapping engine name registered using Database.register_engine --> base class
19
20
  _ENGINE_CLASS_MAPPING = {}
@@ -77,10 +78,7 @@ class RoutingSession(sqlalchemy.orm.Session):
77
78
  raise RuntimeError(f'Did not find an engine for {mapper.class_}')
78
79
 
79
80
  def _bound_execute(self, bind, *args, **kwargs):
80
- if SA_GE_14:
81
- return self.execute(*args, bind_arguments={'bind': bind}, **kwargs)
82
- else:
83
- return self.execute(*args, bind=bind, **kwargs)
81
+ return self.execute(*args, bind_arguments={'bind': bind}, **kwargs)
84
82
 
85
83
  def execute_with_bind(self, engine_name, *args, **kwargs):
86
84
  """
@@ -220,9 +218,11 @@ class Database:
220
218
  location = engine['alembic_location']
221
219
  if location:
222
220
  with alembic_context(engine['engine'], location) as ac:
223
- ac.migration_context.stamp(
224
- ac.script, ac.script.get_current_head()
225
- )
221
+ with ac.migration_context.begin_transaction():
222
+ ac.migration_context.stamp(
223
+ ac.script, ac.script.get_current_head()
224
+ )
225
+
226
226
  if create_defaults:
227
227
  self.create_defaults(engine_name)
228
228
 
@@ -336,10 +336,12 @@ class Database:
336
336
  tables = ', '.join('"%s"' % x for x in table_names)
337
337
  self.session._bound_execute(
338
338
  engine,
339
- 'TRUNCATE {} {} {}'.format(
340
- tables,
341
- 'RESTART IDENTITY' if restart_sequences else '',
342
- 'CASCADE' if cascade else '',
339
+ text(
340
+ 'TRUNCATE {} {} {}'.format(
341
+ tables,
342
+ 'RESTART IDENTITY' if restart_sequences else '',
343
+ 'CASCADE' if cascade else '',
344
+ )
343
345
  ),
344
346
  )
345
347
  zope.sqlalchemy.mark_changed(self.session)
@@ -402,3 +404,5 @@ class AlembicContext:
402
404
  ) as ec:
403
405
  ec.configure(self.conn)
404
406
  ec.run_migrations()
407
+ if hasattr(self.conn, 'commit'):
408
+ self.conn.commit()
@@ -105,6 +105,6 @@ class_registry = {}
105
105
 
106
106
  def declarative_base(cls, **kw):
107
107
  """Create a `declarative_base` from a base Object."""
108
- obj = sqlalchemy.ext.declarative.declarative_base(cls=cls, **kw)
108
+ obj = sqlalchemy.orm.declarative_base(cls=cls, **kw)
109
109
  register_class(obj)
110
110
  return obj
@@ -25,7 +25,9 @@ class LinkedModel(Object):
25
25
  ForeignKey('sequencemodel.id'),
26
26
  primary_key=True,
27
27
  )
28
- sequence_model = sqlalchemy.orm.relation('SequenceModel', uselist=False)
28
+ sequence_model = sqlalchemy.orm.relationship(
29
+ 'SequenceModel', uselist=False
30
+ )
29
31
 
30
32
 
31
33
  class SequenceModel(Object):
@@ -5,7 +5,7 @@ import pytest
5
5
  import risclog.sqlalchemy.model
6
6
  import sqlalchemy
7
7
  import transaction
8
- from sqlalchemy import Column, Integer, String
8
+ from sqlalchemy import Column, Integer, String, text
9
9
 
10
10
  from ..db import _ENGINE_CLASS_MAPPING, Database, get_database, register_class
11
11
  from ..model import ObjectBase, declarative_base
@@ -155,10 +155,12 @@ def test_database_is_detected_automatically_among_several(
155
155
 
156
156
  # When using session.execute, a manual bind is necessary though
157
157
  with pytest.raises(RuntimeError):
158
- assert db.session.execute('SELECT count(*) FROM model_1').fetchall()
158
+ assert db.session.execute(
159
+ text('SELECT count(*) FROM model_1')
160
+ ).fetchall()
159
161
  # Using a bound session leads to a result:
160
162
  assert db.session.using_bind('db1').execute(
161
- 'SELECT count(*) FROM model_1'
163
+ text('SELECT count(*) FROM model_1')
162
164
  ).fetchall() == [(1,)]
163
165
 
164
166