Name | ConnectKit-Database JSON |
Version |
1.3.6
JSON |
| download |
home_page | None |
Summary | Wrapper for connection to database |
upload_time | 2024-11-07 18:35:32 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | The MIT License (MIT)
Copyright © 2024 MTUCI Open Source
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
connectkit
database
postgres
postgresql
mysql
sqlite3
sqlite
mariadb
async
asyncio
sqlalchemy
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# ConnectKit Database [*en*|[ru](./README_RU.md)]
___
ConnectKit Database is a wrapper under SQLAlchemy with some utils.
Include pydantic settings, custom json serializer, template code.
## Installation
___
Three types of connectors are supported:
-[x] PostgreSQL (sync/async)
-[x] MySQL (MariaDB) (sync/async)
-[x] Sqlite3 (sync/async)
By default, the DB connector package is not installed, extensions are specified for installation.
To install sync versions:
```shell
pip install ConnectKit-Database[postgresql] # Установка коннектора PostgreSQL
pip install ConnectKit-Database[mysql] # Установка коннектора MySQL/MariaDB
pip install ConnectKit-Database[all] # Установка всех sync коннекторов
```
To install async versions:
```shell
pip install ConnectKit-Database[asyncpg] # Установка коннектора PostgreSQL
pip install ConnectKit-Database[aiomysql] # Установка коннектора MySQL/MariaDB
pip install ConnectKit-Database[aiosqlite] # Установка коннектора Sqlite3
pip install ConnectKit-Database[asyncall] # Установка всех async коннекторов
```
## Usage
___
Environment variables are used for connection by default.
Variables are extracted from the environment:
DB_ADDR= # Address for default connection to postgres or mysql(mariadb) (default: None)
DB_PORT=5432 # Port for default connection to postgres or mysql(mariadb)
DB_ADAPTER=postgresql # Select default connection dialect (from postgresql, mysql and sqlite)
DB_USERNAME=postgres # Username for default connection postgres or mysql(mariadb)
DB_PASSWORD= # Username for default connection postgres or mysql(mariadb) (default: None)
DB_NAME=postgres # Database for postgres or mysql(mariadb), filepath for sqlite
DB_POOL_TIMEOUT=1 # Global pool timeout for creating new session to DB
DB_ECHO: bool = False # Log all sql statements (for debug purposes)
These variables can be overridden:
```python
from database.settings import settings
settings.DB_ECHO = False
```
> **!! Attention !!**
After creating a default connection, changing the settings variables for it is ignored.
To open a connection, the `Database` and `AsyncDatabase` context managers are used:
```python
from database import Database, AsyncDatabase, AsyncSession
with Database() as db:
db.execute(...)
async with AsyncDatabase() as db:
await db.execute(...)
# For FastAPI:
async def db_dependency() -> AsyncSession:
async with AsyncDatabase() as db:
yield await db.execute(...)
```
The default Base can be used to create models:
```python
from database import Base
from sqlalchemy.orm import Mapped
class Model(Base):
id: Mapped[int]
```
To initialize ORM models via Base for default connection:
```python
from database import init_default_base, async_init_default_base
from database import Base
init_default_base(Base.metadata)
await async_init_default_base(Base.metadata)
```
## License
___
ConnectKit Database is [MIT License](./LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "ConnectKit-Database",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "connectkit, database, postgres, postgresql, mysql, sqlite3, sqlite, mariadb, async, asyncio, sqlalchemy",
"author": null,
"author_email": "RealMetamorph <andr.timchuk@yandex.ru>",
"download_url": "https://files.pythonhosted.org/packages/75/3e/05bd813f28d08601a0a5478da9ab4f319e5f60c9fa26ad2fed90d4569338/connectkit_database-1.3.6.tar.gz",
"platform": null,
"description": "# ConnectKit Database [*en*|[ru](./README_RU.md)]\n\n___\n\nConnectKit Database is a wrapper under SQLAlchemy with some utils.\n\nInclude pydantic settings, custom json serializer, template code.\n\n## Installation\n\n___\n\nThree types of connectors are supported:\n\n-[x] PostgreSQL (sync/async)\n-[x] MySQL (MariaDB) (sync/async)\n-[x] Sqlite3 (sync/async)\n\nBy default, the DB connector package is not installed, extensions are specified for installation.\n\nTo install sync versions:\n\n```shell\npip install ConnectKit-Database[postgresql] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 PostgreSQL\npip install ConnectKit-Database[mysql] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 MySQL/MariaDB\npip install ConnectKit-Database[all] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 sync \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u043e\u0432\n```\n\nTo install async versions:\n\n```shell\npip install ConnectKit-Database[asyncpg] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 PostgreSQL\npip install ConnectKit-Database[aiomysql] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 MySQL/MariaDB\npip install ConnectKit-Database[aiosqlite] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u0430 Sqlite3\npip install ConnectKit-Database[asyncall] # \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0441\u0435\u0445 async \u043a\u043e\u043d\u043d\u0435\u043a\u0442\u043e\u0440\u043e\u0432\n```\n\n## Usage\n\n___\n\nEnvironment variables are used for connection by default.\nVariables are extracted from the environment:\n\n DB_ADDR= # Address for default connection to postgres or mysql(mariadb) (default: None)\n DB_PORT=5432 # Port for default connection to postgres or mysql(mariadb)\n DB_ADAPTER=postgresql # Select default connection dialect (from postgresql, mysql and sqlite)\n DB_USERNAME=postgres # Username for default connection postgres or mysql(mariadb)\n DB_PASSWORD= # Username for default connection postgres or mysql(mariadb) (default: None)\n DB_NAME=postgres # Database for postgres or mysql(mariadb), filepath for sqlite\n DB_POOL_TIMEOUT=1 # Global pool timeout for creating new session to DB\n DB_ECHO: bool = False # Log all sql statements (for debug purposes)\n\nThese variables can be overridden:\n\n```python\nfrom database.settings import settings\n\nsettings.DB_ECHO = False\n```\n\n> **!! Attention !!**\nAfter creating a default connection, changing the settings variables for it is ignored.\n\nTo open a connection, the `Database` and `AsyncDatabase` context managers are used:\n\n```python\nfrom database import Database, AsyncDatabase, AsyncSession\n\nwith Database() as db:\n db.execute(...)\n\nasync with AsyncDatabase() as db:\n await db.execute(...)\n\n\n# For FastAPI:\n\nasync def db_dependency() -> AsyncSession:\n async with AsyncDatabase() as db:\n yield await db.execute(...)\n```\n\nThe default Base can be used to create models:\n\n```python\nfrom database import Base\nfrom sqlalchemy.orm import Mapped\n\n\nclass Model(Base):\n id: Mapped[int]\n```\n\nTo initialize ORM models via Base for default connection:\n\n```python\nfrom database import init_default_base, async_init_default_base\nfrom database import Base\n\ninit_default_base(Base.metadata)\n\nawait async_init_default_base(Base.metadata)\n```\n\n## License\n\n___\n\nConnectKit Database is [MIT License](./LICENSE).",
"bugtrack_url": null,
"license": "The MIT License (MIT)\n Copyright \u00a9 2024 MTUCI Open Source\n \n Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \u201cSoftware\u201d), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n \n The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \u201cAS IS\u201d, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
"summary": "Wrapper for connection to database",
"version": "1.3.6",
"project_urls": {
"Homepage": "https://github.com/mtuciru/ConnectKit-Database",
"Repository": "https://github.com/mtuciru/ConnectKit-Database.git"
},
"split_keywords": [
"connectkit",
" database",
" postgres",
" postgresql",
" mysql",
" sqlite3",
" sqlite",
" mariadb",
" async",
" asyncio",
" sqlalchemy"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e71257dc2c69d685f7431c774c14229b7f9c1d43ace90b5b7acd5bfd01a6c72e",
"md5": "1d7b828a395965940dbc43bd0bca7e96",
"sha256": "b6489a86a5c9fc69032b28b84879622aa518d094ba492442ca7c3f51dc21ddf9"
},
"downloads": -1,
"filename": "connectkit_database-1.3.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1d7b828a395965940dbc43bd0bca7e96",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 9077,
"upload_time": "2024-11-07T18:35:31",
"upload_time_iso_8601": "2024-11-07T18:35:31.250823Z",
"url": "https://files.pythonhosted.org/packages/e7/12/57dc2c69d685f7431c774c14229b7f9c1d43ace90b5b7acd5bfd01a6c72e/connectkit_database-1.3.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "753e05bd813f28d08601a0a5478da9ab4f319e5f60c9fa26ad2fed90d4569338",
"md5": "27cb80a99a4278b775b9262cc9705812",
"sha256": "16c68ff3bbd18039f2d2beebcf46335b58872364db3001b710dde6e2e8861d0b"
},
"downloads": -1,
"filename": "connectkit_database-1.3.6.tar.gz",
"has_sig": false,
"md5_digest": "27cb80a99a4278b775b9262cc9705812",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 7191,
"upload_time": "2024-11-07T18:35:32",
"upload_time_iso_8601": "2024-11-07T18:35:32.886490Z",
"url": "https://files.pythonhosted.org/packages/75/3e/05bd813f28d08601a0a5478da9ab4f319e5f60c9fa26ad2fed90d4569338/connectkit_database-1.3.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-07 18:35:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mtuciru",
"github_project": "ConnectKit-Database",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "connectkit-database"
}