sqlalchemy-adapter
SQLAlchemy Adapter for PyCasbin
Decision gist · record as of 2026-08-14
Yes, if you need to persist pycasbin policies in a relational database. The package is actively maintained, has no known vulnerabilities, and low install friction. It is a straightforward adapter with a narrow, well-defined scope—use it when pycasbin and SQLAlchemy are your architecture; do not install it if you are not already using pycasbin.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a pycasbin model configuration file and an existing or creatable database at the connection string URL.
- Low install friction; pure Python wheel with two runtime dependencies (pycasbin and SQLAlchemy).
- Actively maintained with recent commits and no known vulnerabilities.
License · maintenance · safety
Apache 2.0 (permissive) — Apache 2.0 permissive license allows commercial and private use with minimal restrictions; attribution required but no copyleft obligations.
last release 2025-11-17 (270 days) · last repo commit 2026-05-15 · 7 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,782,012 downloads/mo, #3,567 on PyPI
Alternatives
Verify before relying
pip install sqlalchemy-adapter
import sqlalchemy_adapter
adapter = sqlalchemy_adapter.Adapter('sqlite:///test.db')
# Pass adapter to pycasbin Enforcer with model config file
# Then use Enforcer to check permissions- Whether the adapter supports all SQLAlchemy dialects equally or has known limitations with specific databases.
- Performance characteristics and scalability limits when handling large policy rule sets.
- Backward compatibility guarantees across major version updates.
What it is and what it does
This package acts as a bridge between pycasbin (a policy enforcement library) and any database that SQLAlchemy supports. Instead of storing access-control policies in memory or flat files, you point it at a database connection string, and it handles loading and saving policy rules to a database table. The adapter automatically creates the necessary schema on first use (unless you disable it), and works transparently with pycasbin's Enforcer to persist role-based access control (RBAC), attribute-based access control (ABAC), and access control list (ACL) policies.
Typical usage involves creating an Adapter with a database URL, passing it to a pycasbin Enforcer along with a policy model file, and then using the Enforcer to check permissions. The adapter manages the database interaction; you focus on policy rules and enforcement logic. It supports custom table names and can be configured to skip automatic table creation if your schema is managed separately.
Use it for
- Store and load RBAC policies for a multi-tenant application across application restarts.
- Manage ACL rules in a centralized database so multiple service instances enforce the same permissions.
- Persist dynamic policy changes made at runtime without redeploying or restarting the application.
- Migrate access-control policies between different database backends using SQLAlchemy's dialect abstraction.
- Integrate pycasbin policy enforcement into an existing application that already uses SQLAlchemy for data access.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to persist pycasbin policies in a relational database.
The package is actively maintained, has no known vulnerabilities, and low install friction. It is a straightforward adapter with a narrow, well-defined scope—use it when pycasbin and SQLAlchemy are your architecture; do not install it if you are not already using pycasbin.
Install
sqlalchemy-adapter on PyPI
Before you install
Low install friction; pure Python wheel with two runtime dependencies (pycasbin and SQLAlchemy). Actively maintained with recent commits and no known vulnerabilities.
Requires a pycasbin model configuration file and an existing or creatable database at the connection string URL.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions; attribution required but no copyleft obligations.
Quickstart
pip install sqlalchemy-adapter
import sqlalchemy_adapter
adapter = sqlalchemy_adapter.Adapter('sqlite:///test.db')
# Pass adapter to pycasbin Enforcer with model config file
# Then use Enforcer to check permissions
Verify before relying
- Whether the adapter supports all SQLAlchemy dialects equally or has known limitations with specific databases.
- Performance characteristics and scalability limits when handling large policy rule sets.
- Backward compatibility guarantees across major version updates.
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.3 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagespycasbinSQLAlchemy |
| Maintenance | Actively maintained 270 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,782,012 / month, #3,567 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.9 |
Evidence: sqlalchemy_adapter-1.9.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “casbin sqlalchemy adapter”
- sqlalchemy-adapterBridges PyCasbin access-control policies with SQLAlchemy-supported…
- casbin-sqlalchemy-adapterConnects PyCasbin access control policies to SQLAlchemy-supported…
- casbin-async-sqlalchemy-adapterProvides an asynchronous SQLAlchemy adapter for PyCasbin, enabling…
Give your agent the search over MCP, or paste the wish link into any chat.
More Database packages
psycopg2-binary is a PostgreSQL database adapter for Python that implements the DB API 2.0 specification, enabling Python applications to connect to and query PostgreSQL databases with thread-safe concurrent operations.
Python client library for connecting to and executing commands against Redis key-value stores, supporting both synchronous and asynchronous operations.
Install it if your application needs to interact with Redis; the only prerequisite is a running Redis server instance.
YDB Python SDK is the official client library for connecting to and querying YDB databases from Python applications.
Install it if you need to connect Python applications to YDB databases.
Connects Python applications to Snowflake data warehouses using the DB API 2.0 specification, enabling SQL queries, data transfers, and warehouse operations.
sqlparse tokenizes SQL text into a tree of statements, clauses, and expressions, and provides functions to split scripts, format queries, and inspect parsed tokens without validating dialect or syntax.
Install it if you need to manipulate, format, or analyze SQL text programmatically.
Provides base adapter protocols and shared functionality that database adapters use to integrate with dbt-core, handling connections, dialect translation, relation caching, and core interface management.
See also casbin-async-sqlalchemy-adapter · casbin-sqlalchemy-adapter · casbin · pycasbin · cerbos-sqlalchemy · fastapi-users-db-sqlalchemy · sqlalchemy-firebird · sqlalchemy-jdbcapi · sqlalchemy-ibmi · databases