SQLAlchemy Adapter for PyCasbin
====
[![GitHub Actions](https://github.com/officialpycasbin/sqlalchemy-adapter/workflows/build/badge.svg?branch=master)](https://github.com/officialpycasbin/sqlalchemy-adapter/actions)
[![Coverage Status](https://coveralls.io/repos/github/officialpycasbin/sqlalchemy-adapter/badge.svg)](https://coveralls.io/github/officialpycasbin/sqlalchemy-adapter)
[![Version](https://img.shields.io/pypi/v/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)
[![Pyversions](https://img.shields.io/pypi/pyversions/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)
[![Download](https://img.shields.io/pypi/dm/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)
[![License](https://img.shields.io/pypi/l/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)
SQLAlchemy Adapter is the [SQLAlchemy](https://www.sqlalchemy.org) adapter for [PyCasbin](https://github.com/casbin/pycasbin). With this library, Casbin can load policy from SQLAlchemy supported database or save policy to it.
Based on [Officially Supported Databases](http://www.sqlalchemy.org/), The current supported databases are:
- PostgreSQL
- MySQL
- SQLite
- Oracle
- Microsoft SQL Server
- Firebird
- Sybase
## Installation
```
pip install sqlalchemy_adapter
```
## Simple Example
```python
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
- [PyCasbin](https://github.com/casbin/pycasbin)
### License
This project is licensed under the [Apache 2.0 license](LICENSE).
Raw data
{
"_id": null,
"home_page": "https://github.com/officialpycasbin/sqlalchemy-adapter",
"name": "sqlalchemy-adapter",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.3",
"maintainer_email": null,
"keywords": "casbin, SQLAlchemy, casbin-adapter, rbac, access control, abac, acl, permission",
"author": "Casbin",
"author_email": "admin@casbin.org",
"download_url": "https://files.pythonhosted.org/packages/26/8a/4086a6324053ad9eed9d30ad36c5be97416b4d1b7bcdd4f748119eaf5698/sqlalchemy_adapter-1.3.0.tar.gz",
"platform": null,
"description": "SQLAlchemy Adapter for PyCasbin \n====\n\n[![GitHub Actions](https://github.com/officialpycasbin/sqlalchemy-adapter/workflows/build/badge.svg?branch=master)](https://github.com/officialpycasbin/sqlalchemy-adapter/actions)\n[![Coverage Status](https://coveralls.io/repos/github/officialpycasbin/sqlalchemy-adapter/badge.svg)](https://coveralls.io/github/officialpycasbin/sqlalchemy-adapter)\n[![Version](https://img.shields.io/pypi/v/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)\n[![Pyversions](https://img.shields.io/pypi/pyversions/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)\n[![Download](https://img.shields.io/pypi/dm/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)\n[![License](https://img.shields.io/pypi/l/sqlalchemy-adapter.svg)](https://pypi.org/project/sqlalchemy-adapter/)\n\nSQLAlchemy Adapter is the [SQLAlchemy](https://www.sqlalchemy.org) adapter for [PyCasbin](https://github.com/casbin/pycasbin). With this library, Casbin can load policy from SQLAlchemy supported database or save policy to it.\n\nBased on [Officially Supported Databases](http://www.sqlalchemy.org/), The current supported databases are:\n\n- PostgreSQL\n- MySQL\n- SQLite\n- Oracle\n- Microsoft SQL Server\n- Firebird\n- Sybase\n\n## Installation\n\n```\npip install sqlalchemy_adapter\n```\n\n## Simple Example\n\n```python\nimport sqlalchemy_adapter\nimport casbin\n\nadapter = sqlalchemy_adapter.Adapter('sqlite:///test.db')\n\ne = casbin.Enforcer('path/to/model.conf', adapter)\n\nsub = \"alice\" # the user that wants to access a resource.\nobj = \"data1\" # the resource that is going to be accessed.\nact = \"read\" # the operation that the user performs on the resource.\n\nif e.enforce(sub, obj, act):\n # permit alice to read data1\n pass\nelse:\n # deny the request, show an error\n pass\n```\n\n\n### Getting Help\n\n- [PyCasbin](https://github.com/casbin/pycasbin)\n\n### License\n\nThis project is licensed under the [Apache 2.0 license](LICENSE).\n",
"bugtrack_url": null,
"license": "Apache 2.0",
"summary": "SQLAlchemy Adapter for PyCasbin",
"version": "1.3.0",
"project_urls": {
"Homepage": "https://github.com/officialpycasbin/sqlalchemy-adapter"
},
"split_keywords": [
"casbin",
" sqlalchemy",
" casbin-adapter",
" rbac",
" access control",
" abac",
" acl",
" permission"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "565ec7c25c69c9a797c7dcc7bc6a7a6055348b3eeb314cbbbf0196a6523c2b68",
"md5": "1e65bb81bc71cdc23325c7977e8c82de",
"sha256": "1381496d4cdb1c459918830ad80e478a04b5ac283cd9238505d7d8858d77570d"
},
"downloads": -1,
"filename": "sqlalchemy_adapter-1.3.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1e65bb81bc71cdc23325c7977e8c82de",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.3",
"size": 8963,
"upload_time": "2024-10-26T14:51:52",
"upload_time_iso_8601": "2024-10-26T14:51:52.200441Z",
"url": "https://files.pythonhosted.org/packages/56/5e/c7c25c69c9a797c7dcc7bc6a7a6055348b3eeb314cbbbf0196a6523c2b68/sqlalchemy_adapter-1.3.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "268a4086a6324053ad9eed9d30ad36c5be97416b4d1b7bcdd4f748119eaf5698",
"md5": "ab54f7b79e44dde64b663d3fea7ee756",
"sha256": "e597b5d2d54a456bdcf8a3c7586b238c02aa5688bb3e7468280c37cc95e67be5"
},
"downloads": -1,
"filename": "sqlalchemy_adapter-1.3.0.tar.gz",
"has_sig": false,
"md5_digest": "ab54f7b79e44dde64b663d3fea7ee756",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.3",
"size": 10943,
"upload_time": "2024-10-26T14:51:54",
"upload_time_iso_8601": "2024-10-26T14:51:54.117598Z",
"url": "https://files.pythonhosted.org/packages/26/8a/4086a6324053ad9eed9d30ad36c5be97416b4d1b7bcdd4f748119eaf5698/sqlalchemy_adapter-1.3.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-26 14:51:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "officialpycasbin",
"github_project": "sqlalchemy-adapter",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"lcname": "sqlalchemy-adapter"
}