tortoise-database-url


Nametortoise-database-url JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/waketzheng/database-url
SummaryMake it easy to generate database url.
upload_time2024-10-30 12:45:19
maintainerNone
docs_urlNone
authorWaket Zheng
requires_python<4.0,>=3.8
licenseNone
keywords database-url database_url tortoise-orm
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # database-url
![Python Versions](https://img.shields.io/pypi/pyversions/tortoise-database-url)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![LatestVersionInPypi](https://img.shields.io/pypi/v/tortoise-database-url.svg?style=flat)](https://pypi.org/project/tortoise-database-url/)
[![GithubActionResult](https://github.com/waketzheng/database-url/workflows/ci/badge.svg)](https://github.com/waketzheng/database-url/actions?query=workflow:ci)
[![Coverage Status](https://coveralls.io/repos/github/waketzheng/database-url/badge.svg?branch=main)](https://coveralls.io/github/waketzheng/database-url?branch=main)
![Mypy coverage](https://img.shields.io/badge/mypy-100%25-green.svg)

Toolkit for TortoiseORM to generate database url from Django DATABASES item format.

## Installation

```bash
pip install tortoise-database-url
```

## Usage

- generate

```py
import database_url

db_url = database_url.generate('my_db', engine='mysql', user='root', password='Me@example.com')
print(db_url)
# mysql://root:Me%40example.com@127.0.0.1:3306/my_db

db_url = database_url.generate('db_name', engine='postgres')
print(db_url)
# postgres://postgres:postgres@127.0.0.1:5432/db_name
```

- from_django_item
```py
import pathlib
import database_url

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": pathlib.Path("/tmp") / "db.sqlite3"
    },
}

db_url = database_url.from_django_item(DATABASES["default"])
print(db_url)
# sqlte:///tmp/db.sqlite3
```
See more at:
https://github.com/waketzheng/database-url/blob/main/tests/test_main.py
https://tortoise.github.io/databases.html?h=database

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/waketzheng/database-url",
    "name": "tortoise-database-url",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "database-url, database_url, tortoise-orm",
    "author": "Waket Zheng",
    "author_email": "waketzheng@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d0/f4/42b7357f8947916af1841b60e450608069456bd0f95b9c2ecca95e0dbf90/tortoise_database_url-0.1.3.tar.gz",
    "platform": null,
    "description": "# database-url\n![Python Versions](https://img.shields.io/pypi/pyversions/tortoise-database-url)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![LatestVersionInPypi](https://img.shields.io/pypi/v/tortoise-database-url.svg?style=flat)](https://pypi.org/project/tortoise-database-url/)\n[![GithubActionResult](https://github.com/waketzheng/database-url/workflows/ci/badge.svg)](https://github.com/waketzheng/database-url/actions?query=workflow:ci)\n[![Coverage Status](https://coveralls.io/repos/github/waketzheng/database-url/badge.svg?branch=main)](https://coveralls.io/github/waketzheng/database-url?branch=main)\n![Mypy coverage](https://img.shields.io/badge/mypy-100%25-green.svg)\n\nToolkit for TortoiseORM to generate database url from Django DATABASES item format.\n\n## Installation\n\n```bash\npip install tortoise-database-url\n```\n\n## Usage\n\n- generate\n\n```py\nimport database_url\n\ndb_url = database_url.generate('my_db', engine='mysql', user='root', password='Me@example.com')\nprint(db_url)\n# mysql://root:Me%40example.com@127.0.0.1:3306/my_db\n\ndb_url = database_url.generate('db_name', engine='postgres')\nprint(db_url)\n# postgres://postgres:postgres@127.0.0.1:5432/db_name\n```\n\n- from_django_item\n```py\nimport pathlib\nimport database_url\n\nDATABASES = {\n    \"default\": {\n        \"ENGINE\": \"django.db.backends.sqlite3\",\n        \"NAME\": pathlib.Path(\"/tmp\") / \"db.sqlite3\"\n    },\n}\n\ndb_url = database_url.from_django_item(DATABASES[\"default\"])\nprint(db_url)\n# sqlte:///tmp/db.sqlite3\n```\nSee more at:\nhttps://github.com/waketzheng/database-url/blob/main/tests/test_main.py\nhttps://tortoise.github.io/databases.html?h=database\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Make it easy to generate database url.",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/waketzheng/database-url",
        "Repository": "https://github.com/waketzheng/database-url.git"
    },
    "split_keywords": [
        "database-url",
        " database_url",
        " tortoise-orm"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c95fb47b612b9daa213a25210f8945695f9e292b3e2ee50fff14e9784f92d86",
                "md5": "c7c04b1beabdaa6280c28212bf780a2b",
                "sha256": "8343c3d8b09ff2b92706d41b921b1c900a0e8cac7669fd6b2bdbb80d712a47e0"
            },
            "downloads": -1,
            "filename": "tortoise_database_url-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c7c04b1beabdaa6280c28212bf780a2b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 3485,
            "upload_time": "2024-10-30T12:45:18",
            "upload_time_iso_8601": "2024-10-30T12:45:18.504167Z",
            "url": "https://files.pythonhosted.org/packages/6c/95/fb47b612b9daa213a25210f8945695f9e292b3e2ee50fff14e9784f92d86/tortoise_database_url-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d0f442b7357f8947916af1841b60e450608069456bd0f95b9c2ecca95e0dbf90",
                "md5": "ba1a4cba813100b6cb2371023c582c75",
                "sha256": "23918f7c1b70d7ff91e42f644280835af76da5cb81750fe7e4e382c224d4dd16"
            },
            "downloads": -1,
            "filename": "tortoise_database_url-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "ba1a4cba813100b6cb2371023c582c75",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 2828,
            "upload_time": "2024-10-30T12:45:19",
            "upload_time_iso_8601": "2024-10-30T12:45:19.601545Z",
            "url": "https://files.pythonhosted.org/packages/d0/f4/42b7357f8947916af1841b60e450608069456bd0f95b9c2ecca95e0dbf90/tortoise_database_url-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-30 12:45:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "waketzheng",
    "github_project": "database-url",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "tortoise-database-url"
}
        
Elapsed time: 0.35279s