sqlacfg
Allows you to store configuration in an SQLAlchemy database instead of configuration files. The API is close, but not exactly like configparser and it plugs right into any application that is already using a declarative SQLAlchemy model:
# create a new model to hold the configuration items
class ConfigSetting(Base, ConfigSettingMixin):
__tablename__ = 'configuration'
# instantiate the model with your session
config = Config(ConfigSetting, session)
# now config sections will work like a regular dict
config['section_foo']['bar'] = 123
# values will be json-encoded before being stored (this can be changed)
# to persist changes, simply commit the session
session.commit()
A full, minimal example is a bit more verbose due to the required initial setup:
from sqlacfg import ConfigSettingMixin, Config
from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
Base = declarative_base()
Session = sessionmaker()
class ConfigSetting(Base, ConfigSettingMixin):
__tablename__ = 'configuration'
# for this demonstration, we just create the db in memory
eng = create_engine('sqlite:///:memory:', echo=True)
Base.metadata.create_all(eng)
session = sessionmaker(bind=eng)()
config = Config(ConfigSetting, session)
config['base']['foo'] = 'bar'
config['base']['baz'] = 'baz'
print dict(config['base'].iteritems())
Metadata
Release files for sqlacfg 0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sqlacfg-0.3.tar.gz | 3.0 kB | Without provenance | Details for sqlacfg-0.3.tar.gz |
Release files / sqlacfg-0.3.tar.gz
| Download URL | sqlacfg-0.3.tar.gz |
|---|---|
| Size | 3.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
595e3a6610fe29d6c31958eac39485335b57ecf890b07a7339cb9a199b5dd712
|
|
BLAKE2b-256 checksum How to use checksums |
b5e2ab90c015d58a33836dd3d13e3ce6328e98c324a34fbabfd1ee5d01b1df28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for sqlacfg 0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.