ddcDatabases


NameddcDatabases JSON
Version 1.0.4 PyPI version JSON
download
home_pagehttps://github.com/ddc/ddcDatabases
SummaryCustom Database Queries
upload_time2024-06-18 15:39:00
maintainerDaniel Costa
docs_urlNone
authorDaniel Costa
requires_python<4.0,>=3.10
licenseMIT
keywords python3 databases ddcdatabases
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Few Utility Functions

[![License](https://img.shields.io/github/license/ddc/ddcDatabases.svg?style=plastic)](https://github.com/ddc/ddcDatabases/blob/master/LICENSE)
[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg?style=plastic)](https://www.python.org)
[![PyPi](https://img.shields.io/pypi/v/ddcDatabases.svg?style=plastic)](https://pypi.python.org/pypi/ddcDatabases)
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A//actions-badge.atrox.dev/ddc/ddcDatabases/badge?ref=main&style=plastic&label=build&logo=none)](https://actions-badge.atrox.dev/ddc/ddcDatabases/goto?ref=main)


# Install
```shell
pip install ddcDatabases
```


# Databases
## DBSQLITE
```
class DBSqlite(db_file_path: str, batch_size=100, echo=False, future=True)
```

```python
import sqlalchemy as sa
from ddcDatabases import DBSqlite, DBUtils
dbsqlite = DBSqlite(database_file_path)
with dbsqlite.session() as session:
    stmt = sa.select(Table).where(Table.id == 1)
    db_utils = DBUtils(session)
    results = db_utils.fetchall(stmt)
```


## DBPOSTGRES
  + Using driver "psycopg2" as default
```
class DBPostgres(future=True, echo=False, drivername="psycopg2", **kwargs)
```

```python
import sqlalchemy as sa
from ddcDatabases import DBPostgres, DBUtils
db_configs = {
    "username": username,
    "password": password,
    "host": host,
    "port": port,
    "database": database
}
dbpostgres = DBPostgres(**db_configs)
with dbpostgres.session() as session:
    stmt = sa.select(Table).where(Table.id == 1)
    db_utils = DBUtils(session)
    results = db_utils.fetchall(stmt)
```

+ DBUTILS
  + Uses SQLAlchemy statements
```python
from ddcDatabases import DBUtils
db_utils = DBUtils(session)
db_utils.add(stmt)
db_utils.execute(stmt)
db_utils.fetchall(stmt)
db_utils.fetchone(stmt)
db_utils.fetch_value(stmt)
```


## DBPOSTGRES ASYNC
  + Using driver "asyncpg"
```
class DBPostgresAsync(future=True, echo=False, drivername="asyncpg", **kwargs)
```

```python
import sqlalchemy as sa
from ddcDatabases import DBPostgresAsync, DBUtilsAsync
db_configs = {
    "username": username,
    "password": password,
    "host": host,
    "port": port,
    "database": database
}
dbpostgres = DBPostgresAsync(**db_configs)
async with dbpostgres.session() as session:
    stmt = sa.select(Table).where(Table.id == 1)
    db_utils = DBUtilsAsync(session)
    results = await db_utils.fetchall(stmt)
```

+ DBUTILS ASYNC
  + Uses SQLAlchemy statements
```python
from ddcDatabases import DBUtilsAsync
db_utils = DBUtilsAsync(session)
await db_utils.add(stmt)
await db_utils.execute(stmt)
await db_utils.fetchall(stmt)
await db_utils.fetchone(stmt)
await db_utils.fetch_value(stmt)
```


# Source Code
### Build
```shell
poetry build
```


### Run Tests
```shell
poe test
```


### Get Coverage Report
```shell
poe coverage
```


# License
Released under the [MIT License](LICENSE)


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/ddc/ddcDatabases",
    "name": "ddcDatabases",
    "maintainer": "Daniel Costa",
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "python3, databases, ddcDatabases",
    "author": "Daniel Costa",
    "author_email": "danieldcsta@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/a1/8e/2c0b396e047a8a63d4f588295731213a8fd5741f0e83e6114d00f3f187c4/ddcdatabases-1.0.4.tar.gz",
    "platform": null,
    "description": "# Few Utility Functions\n\n[![License](https://img.shields.io/github/license/ddc/ddcDatabases.svg?style=plastic)](https://github.com/ddc/ddcDatabases/blob/master/LICENSE)\n[![Python](https://img.shields.io/badge/Python-3.10+-blue.svg?style=plastic)](https://www.python.org)\n[![PyPi](https://img.shields.io/pypi/v/ddcDatabases.svg?style=plastic)](https://pypi.python.org/pypi/ddcDatabases)\n[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A//actions-badge.atrox.dev/ddc/ddcDatabases/badge?ref=main&style=plastic&label=build&logo=none)](https://actions-badge.atrox.dev/ddc/ddcDatabases/goto?ref=main)\n\n\n# Install\n```shell\npip install ddcDatabases\n```\n\n\n# Databases\n## DBSQLITE\n```\nclass DBSqlite(db_file_path: str, batch_size=100, echo=False, future=True)\n```\n\n```python\nimport sqlalchemy as sa\nfrom ddcDatabases import DBSqlite, DBUtils\ndbsqlite = DBSqlite(database_file_path)\nwith dbsqlite.session() as session:\n    stmt = sa.select(Table).where(Table.id == 1)\n    db_utils = DBUtils(session)\n    results = db_utils.fetchall(stmt)\n```\n\n\n## DBPOSTGRES\n  + Using driver \"psycopg2\" as default\n```\nclass DBPostgres(future=True, echo=False, drivername=\"psycopg2\", **kwargs)\n```\n\n```python\nimport sqlalchemy as sa\nfrom ddcDatabases import DBPostgres, DBUtils\ndb_configs = {\n    \"username\": username,\n    \"password\": password,\n    \"host\": host,\n    \"port\": port,\n    \"database\": database\n}\ndbpostgres = DBPostgres(**db_configs)\nwith dbpostgres.session() as session:\n    stmt = sa.select(Table).where(Table.id == 1)\n    db_utils = DBUtils(session)\n    results = db_utils.fetchall(stmt)\n```\n\n+ DBUTILS\n  + Uses SQLAlchemy statements\n```python\nfrom ddcDatabases import DBUtils\ndb_utils = DBUtils(session)\ndb_utils.add(stmt)\ndb_utils.execute(stmt)\ndb_utils.fetchall(stmt)\ndb_utils.fetchone(stmt)\ndb_utils.fetch_value(stmt)\n```\n\n\n## DBPOSTGRES ASYNC\n  + Using driver \"asyncpg\"\n```\nclass DBPostgresAsync(future=True, echo=False, drivername=\"asyncpg\", **kwargs)\n```\n\n```python\nimport sqlalchemy as sa\nfrom ddcDatabases import DBPostgresAsync, DBUtilsAsync\ndb_configs = {\n    \"username\": username,\n    \"password\": password,\n    \"host\": host,\n    \"port\": port,\n    \"database\": database\n}\ndbpostgres = DBPostgresAsync(**db_configs)\nasync with dbpostgres.session() as session:\n    stmt = sa.select(Table).where(Table.id == 1)\n    db_utils = DBUtilsAsync(session)\n    results = await db_utils.fetchall(stmt)\n```\n\n+ DBUTILS ASYNC\n  + Uses SQLAlchemy statements\n```python\nfrom ddcDatabases import DBUtilsAsync\ndb_utils = DBUtilsAsync(session)\nawait db_utils.add(stmt)\nawait db_utils.execute(stmt)\nawait db_utils.fetchall(stmt)\nawait db_utils.fetchone(stmt)\nawait db_utils.fetch_value(stmt)\n```\n\n\n# Source Code\n### Build\n```shell\npoetry build\n```\n\n\n### Run Tests\n```shell\npoe test\n```\n\n\n### Get Coverage Report\n```shell\npoe coverage\n```\n\n\n# License\nReleased under the [MIT License](LICENSE)\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Custom Database Queries",
    "version": "1.0.4",
    "project_urls": {
        "Homepage": "https://github.com/ddc/ddcDatabases",
        "Repository": "https://github.com/ddc/ddcDatabases"
    },
    "split_keywords": [
        "python3",
        " databases",
        " ddcdatabases"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dd2e9d0254d9e941604ae333b33b0a70beda77564305ab765dadbd71863affcb",
                "md5": "529d17fafd3a17604d381b70721e2a05",
                "sha256": "4babffec5bf1b577d1976805e6e39ce4b5838acfce842535d1650fed351834e1"
            },
            "downloads": -1,
            "filename": "ddcdatabases-1.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "529d17fafd3a17604d381b70721e2a05",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6509,
            "upload_time": "2024-06-18T15:38:57",
            "upload_time_iso_8601": "2024-06-18T15:38:57.818083Z",
            "url": "https://files.pythonhosted.org/packages/dd/2e/9d0254d9e941604ae333b33b0a70beda77564305ab765dadbd71863affcb/ddcdatabases-1.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a18e2c0b396e047a8a63d4f588295731213a8fd5741f0e83e6114d00f3f187c4",
                "md5": "eab319df0fb1813c820dd98294a272cd",
                "sha256": "7930325630c23b7754e7c0a3e277b229ba671435991d1a18102f6fd9cba34121"
            },
            "downloads": -1,
            "filename": "ddcdatabases-1.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "eab319df0fb1813c820dd98294a272cd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 4914,
            "upload_time": "2024-06-18T15:39:00",
            "upload_time_iso_8601": "2024-06-18T15:39:00.723281Z",
            "url": "https://files.pythonhosted.org/packages/a1/8e/2c0b396e047a8a63d4f588295731213a8fd5741f0e83e6114d00f3f187c4/ddcdatabases-1.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-18 15:39:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ddc",
    "github_project": "ddcDatabases",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ddcdatabases"
}
        
Elapsed time: 0.73906s