This release is a pre-release and may not be stable for production use.
visaplan.zope.reldb
This package simply provides the configuration of a Data source name (DSN), e.g. for use with SQLAlchemy.
For the heavy lifting of integration of database transactions of your relational database (like PostgreSQL or whatever) with the ZODB, you’ll likely want to use something like zope.sqlalchemy, which in turn requires sqlalchemy to talk to the database. However, zope.sqlalchemy doesn’t offer a configuration method for the DSN. This packages offers to store this DSN in the Zope configuration file (parts/clientN/etc/zope.conf).
The idea is: You might have several instances of your Zope (for production, testing, development …), and every now and then you replicate the productive data. With the DSN stored in the ZODB, you’d have this information replicated as well, which might not work for you; you might have different databases on the same database server, or the production server connects to the database by socket which is not possible in your development instance, or whatever.
Features
Stores a DSN string in the Zope configuration and provides a get_dsn function.
With SQLAlchemy installed,
creates an Engine and a DBSession, and
provides an optional .legacy.SQLWrapper context manager class which sports a few simple insert, update, delete, select and query methods
With zope.sqlalchemy installed as well, registers that DBSession for the transaction machinery integration.
Installation
Add the package to your product requirements somehow; since we’ll need to add a product configuration as well, you’ll most likely add it to your eggs value in your buildout script (buildout.cfg):
[buildout]
...
eggs =
your.fancy.product
visaplan.zope.reldb
Add a product configuration there as well, containing your data source name:
[buildout]
...
[instance_base]
...
zope-conf-additional =
<product-config reldb>
dsn postgresql+psycopg2://localhost/mydb
</product-config>
(We follow the convention used by the UnifiedInstaller here; your section(s) might be named differently.)
After running bin/buildout and restarting your Zope instance, the product configuration should have been added to your zope.conf file(s), and your.fancy.product can read the DSN string by calling visaplan.zope.reldb.get_dsn (or, if you have SQLAlchemy, directly use visaplan.zope.reldb.engine.engine).
Remark
“But, can’t my product simply do all this by itself?!”
Sure. Having this as a package helps / helped us to switch a whole bunch of packages from usage of Zope database adapters (stored in the ZODB) to sqlalchemy (with a DSN configured in the zope.conf file(s)).
Contribute
Issue Tracker: https://github.com/visaplan/zope.reldb/issues
Source Code: https://github.com/visaplan/zope.reldb
Support
If you are having issues, please let us know; please use the issue tracker mentioned above.
License
The project is licensed under the GPLv2.
Futher reading
The SQLAlchemy documentation about Database URLs
Contributors
Tobias Herp, tobias.herp@visaplan.com
Changelog
1.0.0 (unreleased)
Initial release. [tobiasherp]
Metadata
Release files for visaplan.zope.reldb 1.0.0.dev2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| visaplan.zope.reldb-1.0.0.dev2.tar.gz | 27.9 kB | Details |
Release files / visaplan.zope.reldb-1.0.0.dev2.tar.gz
| Download URL | visaplan.zope.reldb-1.0.0.dev2.tar.gz |
|---|---|
| Size | 27.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9449754953bafb7a1fd6bf99922c7ac2e7d865f4c5abe5af1cc5660cbf06733c
|
|
BLAKE2b-256 checksum How to use checksums |
29e0a2a9eb09075973d324501e32c44a34821b79e18e03a919fb38be64f34cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.19.0 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.5
|