Skip to main content

Asynchronous SQLAlchemy Adapter for PyCasbin

Project description

async-sqlalchemy-adapter

GitHub Actions Coverage Status Version PyPI - Wheel Pyversions Download License

Asynchronous SQLAlchemy Adapter is the SQLAlchemy adapter for PyCasbin. With this library, Casbin can load policy from SQLAlchemy supported database or save policy to it.

Based on Officially Supported Databases, The current supported databases are:

  • PostgreSQL
  • MySQL
  • MariaDB
  • SQLite
  • Oracle
  • Microsoft SQL Server
  • Firebird

Installation

pip install casbin_async_sqlalchemy_adapter

Simple Example

import casbin_async_sqlalchemy_adapter
import casbin

adapter = casbin_async_sqlalchemy_adapter.Adapter('sqlite+aiosqlite:///test.db')

# or mysql example 
# adapter = casbin_async_sqlalchemy_adapter.Adapter('mysql+aiomysql://user:pwd@127.0.0.1:3306/exampledb')

e = casbin.AsyncEnforcer('path/to/model.conf', adapter)

sub = "alice"  # the user that wants to access a resource.
obj = "data1"  # the resource that is going to be accessed.
act = "read"  # the operation that the user performs on the resource.

if e.enforce(sub, obj, act):
    # permit alice to read data1
    pass
else:
    # deny the request, show an error
    pass

Note that AsyncAdaper must be used for AynscEnforcer.

Getting Help

License

This project is licensed under the Apache 2.0 license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

casbin_async_sqlalchemy_adapter-1.7.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

casbin_async_sqlalchemy_adapter-1.7.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file casbin_async_sqlalchemy_adapter-1.7.0.tar.gz.

File metadata

File hashes

Hashes for casbin_async_sqlalchemy_adapter-1.7.0.tar.gz
Algorithm Hash digest
SHA256 c946bdbb6c1f9a458fc75e86ac5565fd5f0c07704b78d4b57c257b97a06b5c68
MD5 45920fe167cf675416dc11cce4c1a7a2
BLAKE2b-256 322852d18166e54b8f36228212d2ee00ee86b41d492cab18973e324e3523ff36

See more details on using hashes here.

File details

Details for the file casbin_async_sqlalchemy_adapter-1.7.0-py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_async_sqlalchemy_adapter-1.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d0a1ede29303a11eaa79e258579536b45267373cbd8f03e047ae1a399b92344b
MD5 8fac0c3896613cde11ca11cdd730d976
BLAKE2b-256 5af31fa59284c75e6497d1184459e4743f1ceb39125becca0ca0d67c4f385356

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page