{"id":19298206,"url":"https://github.com/casbin/sqlx-adapter","last_synced_at":"2025-10-25T18:03:35.307Z","repository":{"id":212521444,"uuid":"731692228","full_name":"casbin/sqlx-adapter","owner":"casbin","description":"sqlx adapter for Casbin","archived":false,"fork":false,"pushed_at":"2023-12-14T16:47:11.000Z","size":20,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-29T22:37:49.131Z","etag":null,"topics":["abac","acl","adapter","auth","authorization","casbin","go","golang","orm","rbac","sqlx","storage-driver"],"latest_commit_sha":null,"homepage":"https://github.com/casbin/casbin","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/casbin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"github":"casbin"}},"created_at":"2023-12-14T16:46:01.000Z","updated_at":"2024-05-19T00:36:31.000Z","dependencies_parsed_at":"2023-12-14T18:06:06.634Z","dependency_job_id":null,"html_url":"https://github.com/casbin/sqlx-adapter","commit_stats":null,"previous_names":["casbin/sqlx-adapter"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fsqlx-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fsqlx-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fsqlx-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/casbin%2Fsqlx-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/casbin","download_url":"https://codeload.github.com/casbin/sqlx-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240064610,"owners_count":19742347,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["abac","acl","adapter","auth","authorization","casbin","go","golang","orm","rbac","sqlx","storage-driver"],"created_at":"2024-11-09T23:07:15.350Z","updated_at":"2025-10-25T18:03:35.259Z","avatar_url":"https://github.com/casbin.png","language":"Go","funding_links":["https://github.com/sponsors/casbin"],"categories":[],"sub_categories":[],"readme":"# casbin-sqlx-adapter\nsqlx adapter for Casbin https://github.com/casbin/casbin\n\nBased on [sqlx](https://github.com/jmoiron/sqlx), and tested in [MySQL](https://github.com/go-sql-driver/mysql).\n\n## Installation\n\n    go get github.com/memwey/casbin-sqlx-adapter\n\n## Usage example\n\n```go\nopts := \u0026AdapterOptions{\n    DriverName: \"mysql\",\n    DataSourceName: \"root:1234@tcp(127.0.0.1:3306)/yourdb\",\n    TableName: \"casbin_rule\",\n    // or reuse an existing connection:\n    // DB: myDBConn,\n}\n\na := NewAdapterFromOptions(opts)\n// Casbin v2 may return an error\ne, err := casbin.NewEnforcer(\"examples/rbac_model.conf\", a)\nif err != nil {\n    panic(err)\n}\n```\n\n## Notice\n\nThe v2 version of Casbin has some break change, check for the [detail](https://github.com/casbin/casbin/releases/tag/v2.0.0). If you are still using v1 version, use `0.1.x` of this project.\n\nThe implement is kind of different from the [official one](https://casbin.org/docs/en/adapters). In this implement you should create the database and table on your own.\n\nIn my opinion, in a general PRODUCTION environment, the business code can rarely create a database, create a table or drop a table.\n\nThe filtered adapter feature has been added in some adapter implements such as [Xorm Adapter](https://github.com/casbin/xorm-adapter). However, it's not yet documented in the [doc](https://casbin.org/docs/en/adapters). I will add it after it's documented. See this [issue](https://github.com/casbin/casbin/issues/707).\n\n## Thank\n\nSpecial thanks to [Casbin](https://github.com/casbin). They provide a superb authorization library.\n\nSpecial thanks to [sqlx](https://github.com/jmoiron/sqlx). It provides a brilliant set of extensions on go's standard `database/sql` library.\n\nAnd this project is inspected by [Xorm Adapter](https://github.com/casbin/xorm-adapter), [Gorm Adapter](https://github.com/casbin/gorm-adapter), [Beego ORM Adapter](https://github.com/casbin/beego-orm-adapter) and [MySQL adapter\n](https://github.com/casbin/mysql-adapter). Thanks all of them.\n\n## Others\n\nThis is a very first opensource of me and if this project violates any of the opensource guidelines, please contact me. The project is far from perfect, issues and pull requesets are very welcome.\n\n## License\n\nThis project is under Apache 2.0 License. See the [LICENSE](LICENSE) file for the full license text.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fsqlx-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcasbin%2Fsqlx-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcasbin%2Fsqlx-adapter/lists"}