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 sqlalchemy_adapter

Simple Example

import sqlalchemy_adapter
import casbin

adapter = 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

sqlalchemy_adapter-1.3.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

sqlalchemy_adapter-1.3.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file sqlalchemy_adapter-1.3.0.tar.gz.

File metadata

  • Download URL: sqlalchemy_adapter-1.3.0.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for sqlalchemy_adapter-1.3.0.tar.gz
Algorithm Hash digest
SHA256 e597b5d2d54a456bdcf8a3c7586b238c02aa5688bb3e7468280c37cc95e67be5
MD5 ab54f7b79e44dde64b663d3fea7ee756
BLAKE2b-256 268a4086a6324053ad9eed9d30ad36c5be97416b4d1b7bcdd4f748119eaf5698

See more details on using hashes here.

Provenance

File details

Details for the file sqlalchemy_adapter-1.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sqlalchemy_adapter-1.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1381496d4cdb1c459918830ad80e478a04b5ac283cd9238505d7d8858d77570d
MD5 1e65bb81bc71cdc23325c7977e8c82de
BLAKE2b-256 565ec7c25c69c9a797c7dcc7bc6a7a6055348b3eeb314cbbbf0196a6523c2b68

See more details on using hashes here.

Provenance

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