firebirdsql-run


Namefirebirdsql-run JSON
Version 1.1.3 PyPI version JSON
download
home_pagehttps://github.com/deadnews/firebirdsql-run
SummaryFirebirdsql wrapper inspired by subprocess.run
upload_time2024-08-08 17:41:44
maintainerNone
docs_urlNone
authorDeadNews
requires_python<4.0,>=3.10
licenseMIT
keywords firebird sql api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # firebirdsql-run

> [Firebirdsql](https://github.com/nakagami/pyfirebirdsql/) wrapper inspired by [subprocess.run](https://docs.python.org/3/library/subprocess.html#subprocess.run)

[![PyPI: Version](https://img.shields.io/pypi/v/firebirdsql-run?logo=pypi&logoColor=white)](https://pypi.org/project/firebirdsql-run)
[![GitHub: Release](https://img.shields.io/github/v/release/deadnews/firebirdsql-run?logo=github&logoColor=white)](https://github.com/deadnews/firebirdsql-run/releases/latest)
[![Documentation](https://img.shields.io/badge/documentation-gray.svg?logo=materialformkdocs&logoColor=white)](https://deadnews.github.io/firebirdsql-run)
[![CI: pre-commit](https://results.pre-commit.ci/badge/github/DeadNews/firebirdsql-run/main.svg)](https://results.pre-commit.ci/latest/github/deadnews/firebirdsql-run/main)
[![CI: Main](https://img.shields.io/github/actions/workflow/status/deadnews/firebirdsql-run/main.yml?branch=main&logo=github&logoColor=white&label=main)](https://github.com/deadnews/firebirdsql-run/actions/workflows/main.yml)
[![CI: Coverage](https://img.shields.io/codecov/c/github/deadnews/firebirdsql-run?token=OCZDZIYPMC&logo=codecov&logoColor=white)](https://app.codecov.io/gh/deadnews/firebirdsql-run)

**[Installation](#installation)** • **[Examples](#examples)** • **[Env Variables](#env-variables)**

## Installation

```sh
pip install firebirdsql-run
# or
poetry add firebirdsql-run
```

## Examples

Execute a query with read-only access:

```py
from firebirdsql_run import DBAccess, execute

# Execute a query with read-only access.
result = execute(query="SELECT * FROM table", db="database", access=DBAccess.READ_ONLY)

# Output: List of dictionaries containing the query results.
print(result.data)
```

Execute a query with parameters and log the result:

```py
# Execute a query with parameters.
result = execute(query="INSERT INTO customers (name, age) VALUES (?, ?)", params=("John", 25))

# Log the result.
if result.returncode != 0:
    logger.error(result)
else:
    logger.info(result)
```

Execute a query using the existing connection:

```py
# Create a connection object.
conn = connection(db="database", access=DBAccess.READ_ONLY)
# Execute a query using the existing connection.
result = execute(query="SELECT * FROM table", use_conn=conn)
# Close the connection.
conn.close()

# Output: Named tuple representing the completed transaction.
print(result)
```

An example of a successful transaction:

```py
>>> print(result)
CompletedTransaction(
    host="127.0.0.1",
    db="database",
    user="TWUSER",
    access="READ_ONLY",
    returncode=0,
    exception="",
    query="SELECT * FROM table",
    params=(),
    time=0.001,
    data=[
        {'id': 1, 'name': 'John Doe', 'department': 'Sales'},
        {'id': 2, 'name': 'Jane Smith', 'department': 'Sales'},
    ],
)
```

An example of a failed transaction:

```py
>>> print(result)
CompletedTransaction(
    host="127.0.0.1",
    db="database",
    user="TWUSER",
    access="READ_ONLY",
    returncode=1,
    exception="Dynamic SQL Error\nSQL error code = -204\nTable unknown\ntable\nAt line 1, column 15\n",
    query="SELECT * FROM table",
    params=(),
    time=0.001,
    data=[],
)
```

## Env Variables

```ini
FIREBIRD_KEY=
```

The `FIREBIRD_KEY` environment variable can be overridden with the functions argument `passwd`.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/deadnews/firebirdsql-run",
    "name": "firebirdsql-run",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": "firebird, sql, api",
    "author": "DeadNews",
    "author_email": "deadnewsgit@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f6/09/8a6d08ed3f25ebada4a5070f76aa86006a5f9ca0d8a0733783a218493a4d/firebirdsql_run-1.1.3.tar.gz",
    "platform": null,
    "description": "# firebirdsql-run\n\n> [Firebirdsql](https://github.com/nakagami/pyfirebirdsql/) wrapper inspired by [subprocess.run](https://docs.python.org/3/library/subprocess.html#subprocess.run)\n\n[![PyPI: Version](https://img.shields.io/pypi/v/firebirdsql-run?logo=pypi&logoColor=white)](https://pypi.org/project/firebirdsql-run)\n[![GitHub: Release](https://img.shields.io/github/v/release/deadnews/firebirdsql-run?logo=github&logoColor=white)](https://github.com/deadnews/firebirdsql-run/releases/latest)\n[![Documentation](https://img.shields.io/badge/documentation-gray.svg?logo=materialformkdocs&logoColor=white)](https://deadnews.github.io/firebirdsql-run)\n[![CI: pre-commit](https://results.pre-commit.ci/badge/github/DeadNews/firebirdsql-run/main.svg)](https://results.pre-commit.ci/latest/github/deadnews/firebirdsql-run/main)\n[![CI: Main](https://img.shields.io/github/actions/workflow/status/deadnews/firebirdsql-run/main.yml?branch=main&logo=github&logoColor=white&label=main)](https://github.com/deadnews/firebirdsql-run/actions/workflows/main.yml)\n[![CI: Coverage](https://img.shields.io/codecov/c/github/deadnews/firebirdsql-run?token=OCZDZIYPMC&logo=codecov&logoColor=white)](https://app.codecov.io/gh/deadnews/firebirdsql-run)\n\n**[Installation](#installation)** \u2022 **[Examples](#examples)** \u2022 **[Env Variables](#env-variables)**\n\n## Installation\n\n```sh\npip install firebirdsql-run\n# or\npoetry add firebirdsql-run\n```\n\n## Examples\n\nExecute a query with read-only access:\n\n```py\nfrom firebirdsql_run import DBAccess, execute\n\n# Execute a query with read-only access.\nresult = execute(query=\"SELECT * FROM table\", db=\"database\", access=DBAccess.READ_ONLY)\n\n# Output: List of dictionaries containing the query results.\nprint(result.data)\n```\n\nExecute a query with parameters and log the result:\n\n```py\n# Execute a query with parameters.\nresult = execute(query=\"INSERT INTO customers (name, age) VALUES (?, ?)\", params=(\"John\", 25))\n\n# Log the result.\nif result.returncode != 0:\n    logger.error(result)\nelse:\n    logger.info(result)\n```\n\nExecute a query using the existing connection:\n\n```py\n# Create a connection object.\nconn = connection(db=\"database\", access=DBAccess.READ_ONLY)\n# Execute a query using the existing connection.\nresult = execute(query=\"SELECT * FROM table\", use_conn=conn)\n# Close the connection.\nconn.close()\n\n# Output: Named tuple representing the completed transaction.\nprint(result)\n```\n\nAn example of a successful transaction:\n\n```py\n>>> print(result)\nCompletedTransaction(\n    host=\"127.0.0.1\",\n    db=\"database\",\n    user=\"TWUSER\",\n    access=\"READ_ONLY\",\n    returncode=0,\n    exception=\"\",\n    query=\"SELECT * FROM table\",\n    params=(),\n    time=0.001,\n    data=[\n        {'id': 1, 'name': 'John Doe', 'department': 'Sales'},\n        {'id': 2, 'name': 'Jane Smith', 'department': 'Sales'},\n    ],\n)\n```\n\nAn example of a failed transaction:\n\n```py\n>>> print(result)\nCompletedTransaction(\n    host=\"127.0.0.1\",\n    db=\"database\",\n    user=\"TWUSER\",\n    access=\"READ_ONLY\",\n    returncode=1,\n    exception=\"Dynamic SQL Error\\nSQL error code = -204\\nTable unknown\\ntable\\nAt line 1, column 15\\n\",\n    query=\"SELECT * FROM table\",\n    params=(),\n    time=0.001,\n    data=[],\n)\n```\n\n## Env Variables\n\n```ini\nFIREBIRD_KEY=\n```\n\nThe `FIREBIRD_KEY` environment variable can be overridden with the functions argument `passwd`.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Firebirdsql wrapper inspired by subprocess.run",
    "version": "1.1.3",
    "project_urls": {
        "Documentation": "https://deadnews.github.io/firebirdsql-run",
        "Homepage": "https://github.com/deadnews/firebirdsql-run",
        "Repository": "https://github.com/deadnews/firebirdsql-run"
    },
    "split_keywords": [
        "firebird",
        " sql",
        " api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3e6fe548da8a885cc83cb4587a84e8fe914752c99c62659cdcdd0e14afc5d4e",
                "md5": "2eb49a5086c5aeee2a91b38fa68a3997",
                "sha256": "adbcafdf4a1ec9b1d531097111b0c9aab2a61f3d22dd7f1fa7f72c121d23902c"
            },
            "downloads": -1,
            "filename": "firebirdsql_run-1.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2eb49a5086c5aeee2a91b38fa68a3997",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 6588,
            "upload_time": "2024-08-08T17:41:35",
            "upload_time_iso_8601": "2024-08-08T17:41:35.590405Z",
            "url": "https://files.pythonhosted.org/packages/f3/e6/fe548da8a885cc83cb4587a84e8fe914752c99c62659cdcdd0e14afc5d4e/firebirdsql_run-1.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f6098a6d08ed3f25ebada4a5070f76aa86006a5f9ca0d8a0733783a218493a4d",
                "md5": "766ea473d7cb62ec6e3ffb1bb59e0c57",
                "sha256": "31c07bff9b7063f11db5b868ec52ffc2cbbf6db02897a5aae7fce3c7e71b5866"
            },
            "downloads": -1,
            "filename": "firebirdsql_run-1.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "766ea473d7cb62ec6e3ffb1bb59e0c57",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 6122,
            "upload_time": "2024-08-08T17:41:44",
            "upload_time_iso_8601": "2024-08-08T17:41:44.235404Z",
            "url": "https://files.pythonhosted.org/packages/f6/09/8a6d08ed3f25ebada4a5070f76aa86006a5f9ca0d8a0733783a218493a4d/firebirdsql_run-1.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-08 17:41:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "deadnews",
    "github_project": "firebirdsql-run",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "firebirdsql-run"
}
        
Elapsed time: 0.63253s