{"id":15295776,"url":"https://github.com/dymmond/databasez","last_synced_at":"2025-04-13T11:09:05.222Z","repository":{"id":151290820,"uuid":"623889622","full_name":"dymmond/databasez","owner":"dymmond","description":"Async database support for Python","archived":false,"fork":false,"pushed_at":"2025-04-04T19:26:51.000Z","size":2743,"stargazers_count":23,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-13T11:08:39.859Z","etag":null,"topics":["async","asyncio","mysql","mysql-database","postgres","postgresql","sqlalchemy","sqlalchemy-python","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"https://databasez.dymmond.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dymmond.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","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,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["tarsil"]}},"created_at":"2023-04-05T09:59:19.000Z","updated_at":"2025-04-04T06:36:57.000Z","dependencies_parsed_at":"2024-01-24T17:51:17.953Z","dependency_job_id":"7e36c873-52aa-4d93-a2f4-c580605dbb6f","html_url":"https://github.com/dymmond/databasez","commit_stats":{"total_commits":102,"total_committers":4,"mean_commits":25.5,"dds":0.3431372549019608,"last_synced_commit":"9d14ee078724f77d0c3276a4667546830b7bdb04"},"previous_names":["dymmond/databasez"],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dymmond%2Fdatabasez","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dymmond%2Fdatabasez/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dymmond%2Fdatabasez/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dymmond%2Fdatabasez/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dymmond","download_url":"https://codeload.github.com/dymmond/databasez/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248703198,"owners_count":21148118,"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":["async","asyncio","mysql","mysql-database","postgres","postgresql","sqlalchemy","sqlalchemy-python","sqlite","sqlite3"],"created_at":"2024-09-30T18:08:09.957Z","updated_at":"2025-04-13T11:09:05.168Z","avatar_url":"https://github.com/dymmond.png","language":"Python","funding_links":["https://github.com/sponsors/tarsil"],"categories":[],"sub_categories":[],"readme":"# Databasez\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://databasez.dymmond.com\"\u003e\u003cimg src=\"https://res.cloudinary.com/dymmond/image/upload/v1680611626/databasez/logo-cmp_luizb0.png\" alt='databasez'\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cem\u003e🚀 Async database support for Python. 🚀\u003c/em\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/dymmond/databasez/workflows/Test%20Suite/badge.svg?event=push\u0026branch=main\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://github.com/dymmond/databasez/workflows/Test%20Suite/badge.svg?event=push\u0026branch=main\" alt=\"Test Suite\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://pypi.org/project/databasez\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/databasez?color=%2334D058\u0026label=pypi%20package\" alt=\"Package version\"\u003e\n\u003c/a\u003e\n\n\u003ca href=\"https://pypi.org/project/databasez\" target=\"_blank\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/pyversions/databasez.svg?color=%2334D058\" alt=\"Supported Python versions\"\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n---\n\n**Documentation**: [https://databasez.dymmond.com](https://databasez.dymmond.com) 📚\n\n**Source Code**: [https://github.com/dymmond/databasez](https://github.com/dymmond/databasez)\n\n---\n\n## Motivation\n\nThere is a great package from [Encode](https://github.com/encode/databases/) that was doing what\nthis package was forked to do.\n\nFrom a need to extend to new drivers and newest technologies and adding extra features common and\nuseful to the many, [Databases](https://github.com/encode/databases/) was forked to become\n**Databasez**.\n\nThis package is 100% backwards compatible with [Databases](https://github.com/encode/databases/)\nfrom Encode and will remain like this for the time being but adding extra features and regular\nupdates as well as continuing to be community driven.\n\nBy the time this project was created, Databases was yet to merge possible SQLAlchemy 2.0 changes\nfrom the author of this package and therefore, this package aims to unblock\na lot of the projects out there that want SQLAlchemy 2.0 with the best of databases with new features.\n\nA lot of packages depends of Databases and this was the main reason for the fork of **Databasez**.\n\nIt allows you to make queries using the powerful [SQLAlchemy Core][sqlalchemy-core]\nexpression language, and provides support for PostgreSQL, MySQL, SQLite and MSSQL.\n\nDatabasez is suitable for integrating against any async Web framework, such as [Esmerald][esmerald],\n[Starlette][starlette], [Sanic][sanic], [Responder][responder], [Quart][quart], [aiohttp][aiohttp],\n[Tornado][tornado], or [FastAPI][fastapi].\n\nDatabasez was built for Python 3.9+ and on the top of the newest **SQLAlchemy 2** and gives you\nsimple asyncio support for a range of databases.\n\n### Special notes\n\nThis package couldn't exist without [Databases](https://www.encode.io/databasex/) and the continuous work\ndone by the amazing team behind it. For that reason, thank you!\n\n## Installation\n\n```shell\n$ pip install databasez\n```\n\nIf you are interested in using the [test client](./test-client.md), you can also install:\n\n```shell\n$ pip install databasez[testing]\n```\n\n## What does databasez support at the moment\n\nDatabasez currently supports nearly all async drivers of sqlalchemy.\n\nIf this is not enough there are two special dialects with restricted features:\n\n- jdbc: can load nearly any jdbc driver\n- dbapi2: can load nearly any dbapi2 driver (python standard), async as well as sync.\n\n### Driver installation\n\nYou can install the required database drivers with:\n\n#### Postgres\n\n```shell\n$ pip install databasez[asyncpg]\n```\n\n#### MySQL/MariaDB\n\n```shell\n$ pip install databasez[aiomysql]\n```\n\nor\n\n```shell\n$ pip install databasez[asyncmy]\n```\n\n#### SQLite\n\n```shell\n$ pip install databasez[aiosqlite]\n```\n\n#### MSSQL\n\n```shell\n$ pip install databasez[aioodbc]\n```\n\n!!! Note\n    Note that if you are using any synchronous SQLAlchemy functions such as `engine.create_all()`\n    or [alembic][alembic] migrations then you still have to install a synchronous DB driver:\n    [psycopg][psycopg] for PostgreSQL, [pymysql][pymysql] for MySQL and\n    [pyodbc][pyodbc] for SQL Server.\n\n---\n\n## Quickstart\n\nFor a simple quickstart example, we will be creating a simple SQLite database to run some queries\nagainst.\n\nFirst, install the required drivers for `SQLite` and `ipython`. The `ipython` is to have an\ninteractive python shell with some extras. IPython also supports `await`, which is exactly\nwhat we need. [See more details](https://ipython.org/) about it.\n\n**Install the required drivers**\n\n```shell\n$ pip install databasez[aiosqlite]\n$ pip install ipython\n```\n\nNow from the console, we can run a simple example.\n\n\n```python\n# Create a database instance, and connect to it.\nfrom databasez import Database\n\ndatabase = Database(\"sqlite+aiosqlite:///example.db\")\nawait database.connect()\n\n# Create a table.\nquery = \"\"\"CREATE TABLE HighScores (id INTEGER PRIMARY KEY, name VARCHAR(100), score INTEGER)\"\"\"\nawait database.execute(query=query)\n\n# Insert some data.\nquery = \"INSERT INTO HighScores(name, score) VALUES (:name, :score)\"\nvalues = [\n    {\"name\": \"Daisy\", \"score\": 92},\n    {\"name\": \"Neil\", \"score\": 87},\n    {\"name\": \"Carol\", \"score\": 43},\n]\nawait database.execute_many(query=query, values=values)\n\n# Run a database query.\nquery = \"SELECT * FROM HighScores\"\nrows = await database.fetch_all(query=query)\n\nprint(\"High Scores:\", rows)\n```\n\nCheck out the documentation on [making database queries](https://databasez.dymmond.com/queries/)\nfor examples of how to start using databasez together with SQLAlchemy core expressions.\n\n\n[sqlalchemy-core]: https://docs.sqlalchemy.org/en/latest/core/\n[sqlalchemy-core-tutorial]: https://docs.sqlalchemy.org/en/latest/core/tutorial.html\n[alembic]: https://alembic.sqlalchemy.org/en/latest/\n[psycopg]: https://www.psycopg.org/\n[pymysql]: https://github.com/PyMySQL/PyMySQL\n[pyodbc]: https://github.com/mkleehammer/pyodbc\n[asyncpg]: https://github.com/MagicStack/asyncpg\n[aiomysql]: https://github.com/aio-libs/aiomysql\n[asyncmy]: https://github.com/long2ice/asyncmy\n[aiosqlite]: https://github.com/omnilib/aiosqlite\n[aioodbc]: https://aioodbc.readthedocs.io/en/latest/\n\n[esmerald]: https://github.com/dymmond/esmerald\n[starlette]: https://github.com/encode/starlette\n[sanic]: https://github.com/huge-success/sanic\n[responder]: https://github.com/kennethreitz/responder\n[quart]: https://gitlab.com/pgjones/quart\n[aiohttp]: https://github.com/aio-libs/aiohttp\n[tornado]: https://github.com/tornadoweb/tornado\n[fastapi]: https://github.com/tiangolo/fastapi\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdymmond%2Fdatabasez","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdymmond%2Fdatabasez","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdymmond%2Fdatabasez/lists"}