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.2.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sqlalchemy_adapter-1.2.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.2.0.tar.gz
Algorithm Hash digest
SHA256 88cd53390a5524c64d2546419d982bfd4811b73b02b16cd5af0a22fd5150d140
MD5 035598cc3dfe3797323680c7b7221914
BLAKE2b-256 7fbe2540d0a346d8b7185a005bbb78d6fbee3b34841860c6fac80a597f2d72c5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sqlalchemy_adapter-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4486d829150907cab875b75886a374a0a2e668899e97f79b40bded5ea89040f1
MD5 ab8ad0b5db3bf1acca76996c55c79b5e
BLAKE2b-256 dd274879034b6a7237cac179b3d34fc8e74ce56f302f102e22064470ea0b29fa

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