casbin-sqlalchemy-adapter
SQLAlchemy Adapter for PyCasbin
Decision gist · record as of 2026-08-14
Yes, if you are already using PyCasbin and need to persist policies in a relational database. The low install friction, permissive license, and broad database support make it a straightforward choice for that use case. However, note that maintenance is dormant (no release in 767 days), so if you encounter bugs or need features, you may need to fork or patch it yourself. No known vulnerabilities as of the query date.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires a Casbin model configuration file (model.conf) defining your access control rules and a supported SQLAlchemy database connection string.
- Low friction install with two runtime dependencies (casbin and SQLAlchemy).
- Maintenance is dormant—last release was 767 days ago—but the repository remains active with a recent commit on 2024-07-08 and no archived status.
License · maintenance · safety
Apache 2.0 (permissive) — Licensed under Apache 2.0 (permissive), so you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2024-07-08 (767 days) · last repo commit 2024-07-08 · 82 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 400,666 downloads/mo, #6,936 on PyPI
Alternatives
Verify before relying
pip install casbin_sqlalchemy_adapter
import casbin_sqlalchemy_adapter
import casbin
adapter = casbin_sqlalchemy_adapter.Adapter('sqlite:///test.db')
e = casbin.Enforcer('path/to/model.conf', adapter)
if e.enforce("alice", "data1", "read"):
# permit alice to read data1
pass- Whether soft delete functionality works reliably with all supported database backends.
- Performance characteristics when enforcing policies against large rule sets in production.
- Compatibility with recent major versions of SQLAlchemy (1.4+) beyond what classifiers indicate.
What it is and what it does
This package bridges PyCasbin (a flexible access control library) and SQLAlchemy, letting you store and retrieve authorization policies in any database that SQLAlchemy supports. Instead of keeping policies in memory or in a static file, you define your access control model in Casbin's configuration format and let this adapter handle reading and writing rules to your database of choice—PostgreSQL, MySQL, SQLite, Oracle, SQL Server, Firebird, or Sybase.
You instantiate an Adapter with a database connection string, pass it to a Casbin Enforcer along with your model configuration, and then use Casbin's standard enforce() method to check whether a subject (user) can perform an action on an object (resource). The adapter also supports soft-delete semantics if you need to mark rules as deleted without removing them from the database, though you must implement the deletion timestamp logic yourself.
Use it for
- Store RBAC (role-based access control) rules in PostgreSQL for a multi-tenant SaaS application where policies change frequently.
- Persist ABAC (attribute-based access control) policies in SQLite for a desktop application that needs offline policy evaluation.
- Load access control lists from an existing Oracle database to enforce fine-grained permissions in a legacy system migration.
- Implement soft-delete auditing of permission changes by marking rules as deleted while preserving a historical record.
- Centralize authorization policy management across microservices by storing all rules in a shared MySQL database.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you are already using PyCasbin and need to persist policies in a relational database.
The low install friction, permissive license, and broad database support make it a straightforward choice for that use case. However, note that maintenance is dormant (no release in 767 days), so if you encounter bugs or need features, you may need to fork or patch it yourself. No known vulnerabilities as of the query date.
Install
casbin-sqlalchemy-adapter on PyPI
Before you install
Low friction install with two runtime dependencies (casbin and SQLAlchemy). Maintenance is dormant—last release was 767 days ago—but the repository remains active with a recent commit on 2024-07-08 and no archived status.
Requires a Casbin model configuration file (model.conf) defining your access control rules and a supported SQLAlchemy database connection string.
License in practice
Licensed under Apache 2.0 (permissive), so you can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
Quickstart
pip install casbin_sqlalchemy_adapter
import casbin_sqlalchemy_adapter
import casbin
adapter = casbin_sqlalchemy_adapter.Adapter('sqlite:///test.db')
e = casbin.Enforcer('path/to/model.conf', adapter)
if e.enforce("alice", "data1", "read"):
# permit alice to read data1
pass
Verify before relying
- Whether soft delete functionality works reliably with all supported database backends.
- Performance characteristics when enforcing policies against large rule sets in production.
- Compatibility with recent major versions of SQLAlchemy (1.4+) beyond what classifiers indicate.
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 packagescasbinSQLAlchemy |
| Maintenance | Dormant 767 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 400,666 / month, #6,936 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: casbin_sqlalchemy_adapter-1.4.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 › “rbac permission storage”
- casbin-sqlalchemy-adapterConnects PyCasbin access control policies to SQLAlchemy-supported…
- casbin-async-sqlalchemy-adapterProvides an asynchronous SQLAlchemy adapter for PyCasbin, enabling…
- oslo.policyoslo.policy enforces role-based access control (RBAC) policies across…
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 · sqlalchemy-adapter · casbin · pycasbin · sqlalchemy-jdbcapi · sqlalchemy-firebird · cerbos-sqlalchemy · django-db-connection-pool · databases · fastapi-users-db-sqlalchemy