Skip to main content

SQLAlchemy Adapter for PyCasbin

Project description

SQLAlchemy Adapter for PyCasbin

GitHub Actions Coverage Status Version PyPI - Wheel Pyversions Download License

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
  • SQLite
  • Oracle
  • Microsoft SQL Server
  • Firebird
  • Sybase

Installation

pip install casbin_sqlalchemy_adapter

Simple Example

import casbin_sqlalchemy_adapter
import casbin

adapter = casbin_sqlalchemy_adapter.Adapter('sqlite:///test.db')

e = casbin.Enforcer('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

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_sqlalchemy_adapter-0.5.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

casbin_sqlalchemy_adapter-0.5.1-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file casbin_sqlalchemy_adapter-0.5.1.tar.gz.

File metadata

File hashes

Hashes for casbin_sqlalchemy_adapter-0.5.1.tar.gz
Algorithm Hash digest
SHA256 9a4cfe5d617cebf3cb4e8a6f883c8ef3b7676d9e6041b7ec82e43610a0408d7d
MD5 5624b90c8c0e78ed360f23af21ba51e2
BLAKE2b-256 fc0f9ac478f57b4f8c43df7d98b4c9ebaa6296cd3ee7e4a157e4f1ad839c0754

See more details on using hashes here.

File details

Details for the file casbin_sqlalchemy_adapter-0.5.1-py3-none-any.whl.

File metadata

File hashes

Hashes for casbin_sqlalchemy_adapter-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91f32b7d0a9b524932cee928d2803f06c9b864f41797a0ceabf49b9bebcbd606
MD5 4b6b3b16fbe28ab48eb6192691f8ab84
BLAKE2b-256 e298403f9b9dc5c6eaec28cb5c120469d7e81e578b88d127a3942b5f073ac447

See more details on using hashes here.

Supported by

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