# DbYoke
DbYoke is a library designed to standardize database connections. It supports multiple drivers (PostgreSQL,
MSSQL, Oracle) and simplifies connection string generation and connection management.
## Features
- Simplified database connection management.
- Support for PostgreSQL, Microsoft SQL Server, and Oracle.
- Unified interface for working with database drivers.
- Connection string generation.
---
## Installation
You can install **DbYoke** using `pip install dbyoke`.
### Install from PyPI
To install the library with all available drivers:
```bash
pip install dbyoke[all]
```
To install only specific drivers, use the following commands:
• For PostgreSQL:
```bash
pip install dbyoke[postgresql]
```
• For Oracle:
```bash
pip install dbyoke[oracle]
```
• For MSSQL:
```bash
pip install dbyoke[mssql]
```
Optional Dependencies
DbYoke provides optional dependencies for different database drivers. You can install the specific drivers you need by using the extras feature of pip. For example, to install support for PostgreSQL, you can use:
```bash
pip install dbyoke[postgresql]
```
## Quick Start
Connecting to a Database
Example for PostgreSQL
```py
from dbyoke.connection import DatabaseConnection
config = {
"db_type": "postgresql",
"dbname": "example_db",
"user": "admin",
"password": "secret",
"host": "localhost",
"port": 5432
}
with DatabaseConnection(config) as db:
connection = db.connect()
cursor = connection.cursor()
cursor.execute("SELECT * FROM my_table")
print(cursor.fetchall())
```
Example for MSSQL
```py
from dbyoke.connection import DatabaseConnection
config = {
"db_type": "mssql",
"dbname": "example_db",
"user": "admin",
"password": "secret",
"host": "localhost",
"driver": "{ODBC Driver 18 for SQL Server}",
"trust_certificate": "yes"
}
with DatabaseConnection(config) as db:
connection = db.connect()
cursor = connection.cursor()
cursor.execute("SELECT 1")
print(cursor.fetchall())
```
Generating a Connection String
```py
from dbyoke.connection_string import ConnectionStringBuilder
config = {
"db_type": "oracle",
"user": "system",
"password": "oracle",
"host": "localhost",
"port": 1521,
"service_name": "XE"
}
builder = ConnectionStringBuilder(config)
print(builder.build())
# Output: "system/oracle@localhost:1521/XE"
```
## Logging
To enable logging, you can use the following utility function:
```py
from dbyoke.utils import configure_logging
logger = configure_logging(level="DEBUG")
```
## Supported Databases
| Database Type | Driver | Dependency |
|---------------|----------------|-------------------|
| PostgreSQL | Psycopg2Driver | `psycopg2-binary` |
| MSSQL | PyODBCDriver | `pyodbc` |
| Oracle | OracleDriver | `oracledb` |
Raw data
{
"_id": null,
"home_page": "https://github.com/datadev13/dbyoke",
"name": "dbyoke",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "database connection drivers unification",
"author": "datadev13",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/bb/34/f1d235c030cf859663015a1025a40eb904c5d44703035a8271366a3c185c/dbyoke-0.1.3.tar.gz",
"platform": null,
"description": "# DbYoke\n\nDbYoke is a library designed to standardize database connections. It supports multiple drivers (PostgreSQL,\nMSSQL, Oracle) and simplifies connection string generation and connection management.\n\n## Features\n\n- Simplified database connection management.\n- Support for PostgreSQL, Microsoft SQL Server, and Oracle.\n- Unified interface for working with database drivers.\n- Connection string generation.\n\n---\n\n## Installation\n\nYou can install **DbYoke** using `pip install dbyoke`.\n\n### Install from PyPI\n\nTo install the library with all available drivers:\n\n```bash\npip install dbyoke[all]\n```\nTo install only specific drivers, use the following commands:\n\n\u2022\tFor PostgreSQL:\n```bash\npip install dbyoke[postgresql]\n```\n\u2022\tFor Oracle:\n```bash\npip install dbyoke[oracle]\n```\n\u2022\tFor MSSQL:\n```bash\npip install dbyoke[mssql]\n```\n\nOptional Dependencies\n\nDbYoke provides optional dependencies for different database drivers. You can install the specific drivers you need by using the extras feature of pip. For example, to install support for PostgreSQL, you can use:\n```bash\npip install dbyoke[postgresql]\n```\n\n## Quick Start\n\nConnecting to a Database\n\nExample for PostgreSQL\n\n```py\nfrom dbyoke.connection import DatabaseConnection\n\nconfig = {\n \"db_type\": \"postgresql\",\n \"dbname\": \"example_db\",\n \"user\": \"admin\",\n \"password\": \"secret\",\n \"host\": \"localhost\",\n \"port\": 5432\n}\n\nwith DatabaseConnection(config) as db:\n connection = db.connect()\n cursor = connection.cursor()\n cursor.execute(\"SELECT * FROM my_table\")\n print(cursor.fetchall())\n```\n\nExample for MSSQL\n\n```py\nfrom dbyoke.connection import DatabaseConnection\n\nconfig = {\n \"db_type\": \"mssql\",\n \"dbname\": \"example_db\",\n \"user\": \"admin\",\n \"password\": \"secret\",\n \"host\": \"localhost\",\n \"driver\": \"{ODBC Driver 18 for SQL Server}\",\n \"trust_certificate\": \"yes\"\n}\n\nwith DatabaseConnection(config) as db:\n connection = db.connect()\n cursor = connection.cursor()\n cursor.execute(\"SELECT 1\")\n print(cursor.fetchall())\n```\n\nGenerating a Connection String\n\n```py\nfrom dbyoke.connection_string import ConnectionStringBuilder\n\nconfig = {\n \"db_type\": \"oracle\",\n \"user\": \"system\",\n \"password\": \"oracle\",\n \"host\": \"localhost\",\n \"port\": 1521,\n \"service_name\": \"XE\"\n}\n\nbuilder = ConnectionStringBuilder(config)\nprint(builder.build())\n# Output: \"system/oracle@localhost:1521/XE\"\n```\n\n## Logging\n\nTo enable logging, you can use the following utility function:\n\n```py\nfrom dbyoke.utils import configure_logging\n\nlogger = configure_logging(level=\"DEBUG\")\n```\n\n## Supported Databases\n\n| Database Type | Driver | Dependency |\n|---------------|----------------|-------------------|\n| PostgreSQL | Psycopg2Driver | `psycopg2-binary` |\n| MSSQL | PyODBCDriver | `pyodbc` |\n| Oracle | OracleDriver | `oracledb` |\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A library to unify database connections and drivers",
"version": "0.1.3",
"project_urls": {
"Homepage": "https://github.com/datadev13/dbyoke"
},
"split_keywords": [
"database",
"connection",
"drivers",
"unification"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "2d952c2cdb29ea94c618be109def581a7cf232274f2fa042f314f3198f261c40",
"md5": "fbb431096d6d0d78772229e9eecf3d57",
"sha256": "2a84168804140d22785948cb58c5db10c0f6d0b85e72c85273221864617e565c"
},
"downloads": -1,
"filename": "dbyoke-0.1.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "fbb431096d6d0d78772229e9eecf3d57",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 8581,
"upload_time": "2024-11-26T18:15:30",
"upload_time_iso_8601": "2024-11-26T18:15:30.955329Z",
"url": "https://files.pythonhosted.org/packages/2d/95/2c2cdb29ea94c618be109def581a7cf232274f2fa042f314f3198f261c40/dbyoke-0.1.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "bb34f1d235c030cf859663015a1025a40eb904c5d44703035a8271366a3c185c",
"md5": "0f9da2ec9ccb9e3cd2fb84bcd7b68712",
"sha256": "f92183a321e031440a09439d9a781606d92f4c92b2ea2273fad28542700edf85"
},
"downloads": -1,
"filename": "dbyoke-0.1.3.tar.gz",
"has_sig": false,
"md5_digest": "0f9da2ec9ccb9e3cd2fb84bcd7b68712",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 7366,
"upload_time": "2024-11-26T18:15:32",
"upload_time_iso_8601": "2024-11-26T18:15:32.702128Z",
"url": "https://files.pythonhosted.org/packages/bb/34/f1d235c030cf859663015a1025a40eb904c5d44703035a8271366a3c185c/dbyoke-0.1.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-26 18:15:32",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "datadev13",
"github_project": "dbyoke",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "dbyoke"
}