Registry /
database / casbin-async-sqlalchemy-adapter
Install & Compatibility
Where this runs
tested against v1.17.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 1.080s · 47MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.7s · import 0.948s · 45MB
46MB installed
● package 46MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Adapter
✓ from casbin_async_sqlalchemy_adapter import Adapter
✗ from casbin_async_sqlalchemy_adapter.adapter import Adapter
Old import path (submodule) no longer works; use top-level import.
Basic usage with sqlite+aiosqlite. Ensure you have aiosqlite installed. The adapter must be initialized with create_table() before use.
import asyncio
from casbin import Enforcer
from casbin_async_sqlalchemy_adapter import Adapter
async def main():
adapter = Adapter('sqlite+aiosqlite:///test.db')
# Initialize adapter (creates table)
await adapter.create_table()
e = Enforcer('path/to/model.conf', adapter)
# ... use enforcer
await e.enforce('alice', 'data1', 'read')
asyncio.run(main())
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'casbin_async_sqlalchemy_adapter'
Library not installed or installed without async SQLAlchemy driver.
fixpip install casbin-async-sqlalchemy-adapter aiosqlite
AttributeError: 'Adapter' object has no attribute 'create_table'
Using an outdated version or incorrect import path.
fixImport Adapter from top-level and ensure version >=1.0.0.
sqlalchemy.exc.ArgumentError: Could not parse rfc1738 URL from string 'sqlite:///test.db'
Using sync SQLAlchemy URL without async driver prefix.
fixUse 'sqlite+aiosqlite:///test.db' for async SQLite.
Upgrade
Version history
1.17.0latest on PyPI · released Dec 10, 2025
Audit
Dependencies
casbinrequiredCore library; adapter is useless without it.
sqlalchemyrequiredORM used for database operations.
asynciorequiredAsync runtime support.