Skip to main content

flypper-sqlalchemy

Flypper-sqlalchemy is a storage backend for the flypper package.

It is backed by a RDBMS through the SQL-Alchemy library so it an be used in a distributed environment and be persisted across restarts.

Installation

Use the package manager pip to install flypper-sqlalchemy.

pip install flypper-sqlalchemy

Usage

Build a storage backend:

from flypper_sqlalchemy.storage.sqla import SqlAlchemyStorage

# Create tables, make sure they are created, for instance with `create_all()`.
SqlAlchemyStorage.build_flags_table(sqla_metadata=metadata)
SqlAlchemyStorage.build_metadata_table(sqla_metadata=metadata)

storage = SqlAlchemyStorage(session=session_proxy)

# Or instead, depending on the use-case:
#
# storage = SqlAlchemyStorage(engine=engine)
)

Use it in the web UI:

from flypper.wsgi.web_ui import FlypperWebUI

web_ui = FlypperWebUI(storage=storage)

Use it in your code:

  1. Build a client for your app
  2. Use a context
from flypper.client import Client as FlypperClient

# Once per thread
flypper_client = FlypperClient(storage=storage, ttl=10)

# Once per request
flypper_context = FlypperContext(
    client=flypper_client,
    entries={"user_id": "42"},
)

# Every time you need
flypper_context.is_enabled("flag_name")
flypper_context.is_enabled(
    "other_flag_name",
    entries={"item_reference": "blue-shampoo"},
)

Q&A

How to use the ORM layer of SQL-Alchemy?

We can use the Hybrid Declarative mapping capability to build a mapped class from flypper's tables:

from sqlalchemy.ext.declarative import declarative_base

from flypper_sqlalchemy.storage.sqla import SqlAlchemyStorage

Base = declarative_base()

class FlypperFlag(Base):
    __table__ = SqlAlchemyStorage.build_flags_table(
        sqla_metadata=Base.metadata,
    )

class FlypperMetadata(Base):
    __table__ = SqlAlchemyStorage.build_metadata_table(
        sqla_metadata=Base.metadata,
    )

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

Metadata

Release files for flypper-sqlalchemy 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flypper-sqlalchemy 0.1.6
File Size Uploaded Provenance Actions
flypper-sqlalchemy-0.1.6.tar.gz 4.9 kB Without provenance Details for flypper-sqlalchemy-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flypper-sqlalchemy 0.1.6
File Interpreter ABI Platform Actions
flypper_sqlalchemy-0.1.6-py3-none-any.whl Python 3 none any Details for flypper_sqlalchemy-0.1.6-py3-none-any.whl

Total release size: 12.0 kB

Release files / flypper-sqlalchemy-0.1.6.tar.gz

Download URL flypper-sqlalchemy-0.1.6.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
08cbd20a3b385df808d1953a0cf47273f3594bb1d48c11617f96197ca34b6526
BLAKE2b-256 checksum
How to use checksums
f76dd1b72bdb71b159fdbabd777a88017017d1030ba4d5cfcecd860950f3d401
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.5 Linux/5.11.0-7633-generic

Release files / flypper_sqlalchemy-0.1.6-py3-none-any.whl

Download URL flypper_sqlalchemy-0.1.6-py3-none-any.whl
Size 7.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
38bea363b0a93e29f9439adcf6ecef12f98bf52c1d10b9308673707b0b908091
BLAKE2b-256 checksum
How to use checksums
8ec98bc3f7634880e375404ca027221061cca053937302a83651739c8171918b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.11 CPython/3.9.5 Linux/5.11.0-7633-generic

Security for flypper-sqlalchemy 0.1.6

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page