rest-mysql


Namerest-mysql JSON
Version 1.2.6 PyPI version JSON
download
home_pageNone
SummaryStand alone version of Record_MySQL from Rest-OC to facilitate updating code to newer librairies. Has since been updated far beyond Rest-OC.
upload_time2025-09-02 16:47:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords
VCS
bugtrack_url
requirements arrow config-oc DBUtils define-oc json-fix jsonb PyMySQL tools-oc
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # rest_mysql
[![pypi version](https://img.shields.io/pypi/v/rest_mysql.svg)](https://pypi.org/project/rest_mysql) ![MIT License](https://img.shields.io/pypi/l/rest_mysql.svg)

Stand alone version of Record_MySQL from Rest-OC to facilitate updating code to
newer librairies. Since forking off of Rest-OC numerous improvements and bug
fixes have been done.

See [Releases](https://github.com/ouroboroscoding/rest_mysql/blob/main/releases.md)
for changes from release to release.

[Full Documentation](https://github.com/ouroboroscoding/rest_mysql/blob/main/documentation.md)

## Install

### Requires
rest_mysql requires python 3.10 or higher

### Install via pip
```bash
pip install rest_mysql
```

## Updating from Rest-OC
Instead of pulling Record_MySQL from RestOC as we did in the past, change any
references to rest_mysql

Old:
```python
from RestOC import Record_MySQL
from RestOC.Record_MySQL import db_create, Record
from RestOC.Record_Base import register_type
```

New:
```python
from rest_mysql import Record_MySQL
from rest_mysql.Record_MySQL import db_create, Record
from rest_mysql.Record_Base import register_type
```

## Binary UUID and UUIDv4

If you're using `uuid` or `uuid4` [define](https://pypi.org/project/define-oc/)
types and you run into problems with UUID_TO_BIN and BIN_TO_UUID, you will need
to install the functions, or an alias

### Note

Before continuing, I would suggest switching to `tuuid` or `tuuid4` as these
represent trimmed UUIDs, which can be turned to binary and back without the use
of UUID_TO_BIN or BIN_TO_UUID. If you absolutely must have full UUIDs, then
choose from the below server types to continue fixing the issue.

### MySQL

MySQL provides the functions, but in order for `rest_mysql` to be supportive of
all system, it defaults to assuming the function is part of the database schema.
To solve this, make aliases to the global functons

```python
from rest_mysql.Record_MySQL import Commands

db = 'your_db_name'
Commands.execute('primary', [

	"CREATE FUNCTION `%s`.`BIN_TO_UUID`(b BINARY(16))\n" \
	"RETURNS CHAR(36) DETERMINISTIC\n" \
	"BEGIN\n" \
	"	return BIN_TO_UUID(b);\n" \
	"END" % db,

	"CREATE FUNCTION `%s`.`UUID_TO_BIN`(uuid CHAR(36))\n" \
	"RETURNS BINARY(16) DETERMINISTIC\n" \
	"BEGIN\n" \
	"	RETURN UUID_TO_BIN(uuid);\n" \
	"END" % db
])
```

### MariaDB

MariaDB does not provide UUID_TO_BIN and BIN_TO_UUID as it has its own uuid type
which doesn't support the standard sql way of storing binary UUIDs. You can add
the functions to the database schema like so

```python
from rest_mysql.Record_MySQL import Commands

db = 'your_db_name'
Commands.execute('primary', [

	"CREATE FUNCTION `%s`.`BIN_TO_UUID`(b BINARY(16))\n" \
	"RETURNS CHAR(36) DETERMINISTIC\n" \
	"BEGIN\n" \
	"	DECLARE hexStr CHAR(32);\n" \
	"	SET hexStr = HEX(b);\n" \
	"	RETURN LOWER(CONCAT(" \
			"SUBSTR(hexStr, 1, 8), '-', " \
			"SUBSTR(hexStr, 9, 4), '-', " \
			"SUBSTR(hexStr, 13, 4), '-', " \
			"SUBSTR(hexStr, 17, 4), '-', " \
			"SUBSTR(hexStr, 21)" \
		"));\n" \
	"END" % db,

	"CREATE FUNCTION `%s`.`UUID_TO_BIN`(uuid CHAR(36))\n" \
	"RETURNS BINARY(16) DETERMINISTIC\n" \
	"BEGIN\n" \
		"RETURN UNHEX(REPLACE(uuid, '-', ''));\n" \
	"END" % db
])
```
            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "rest-mysql",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "\"Chris Nasr - Ouroboros Coding Inc.\" <chris@ouroboroscoding.com>",
    "keywords": null,
    "author": null,
    "author_email": "\"Chris Nasr - Ouroboros Coding Inc.\" <chris@ouroboroscoding.com>",
    "download_url": "https://files.pythonhosted.org/packages/0f/22/ba24462ae220f3046232d46e0a64f7e76a6167a41d5c2f754b67c964cb82/rest_mysql-1.2.6.tar.gz",
    "platform": null,
    "description": "# rest_mysql\n[![pypi version](https://img.shields.io/pypi/v/rest_mysql.svg)](https://pypi.org/project/rest_mysql) ![MIT License](https://img.shields.io/pypi/l/rest_mysql.svg)\n\nStand alone version of Record_MySQL from Rest-OC to facilitate updating code to\nnewer librairies. Since forking off of Rest-OC numerous improvements and bug\nfixes have been done.\n\nSee [Releases](https://github.com/ouroboroscoding/rest_mysql/blob/main/releases.md)\nfor changes from release to release.\n\n[Full Documentation](https://github.com/ouroboroscoding/rest_mysql/blob/main/documentation.md)\n\n## Install\n\n### Requires\nrest_mysql requires python 3.10 or higher\n\n### Install via pip\n```bash\npip install rest_mysql\n```\n\n## Updating from Rest-OC\nInstead of pulling Record_MySQL from RestOC as we did in the past, change any\nreferences to rest_mysql\n\nOld:\n```python\nfrom RestOC import Record_MySQL\nfrom RestOC.Record_MySQL import db_create, Record\nfrom RestOC.Record_Base import register_type\n```\n\nNew:\n```python\nfrom rest_mysql import Record_MySQL\nfrom rest_mysql.Record_MySQL import db_create, Record\nfrom rest_mysql.Record_Base import register_type\n```\n\n## Binary UUID and UUIDv4\n\nIf you're using `uuid` or `uuid4` [define](https://pypi.org/project/define-oc/)\ntypes and you run into problems with UUID_TO_BIN and BIN_TO_UUID, you will need\nto install the functions, or an alias\n\n### Note\n\nBefore continuing, I would suggest switching to `tuuid` or `tuuid4` as these\nrepresent trimmed UUIDs, which can be turned to binary and back without the use\nof UUID_TO_BIN or BIN_TO_UUID. If you absolutely must have full UUIDs, then\nchoose from the below server types to continue fixing the issue.\n\n### MySQL\n\nMySQL provides the functions, but in order for `rest_mysql` to be supportive of\nall system, it defaults to assuming the function is part of the database schema.\nTo solve this, make aliases to the global functons\n\n```python\nfrom rest_mysql.Record_MySQL import Commands\n\ndb = 'your_db_name'\nCommands.execute('primary', [\n\n\t\"CREATE FUNCTION `%s`.`BIN_TO_UUID`(b BINARY(16))\\n\" \\\n\t\"RETURNS CHAR(36) DETERMINISTIC\\n\" \\\n\t\"BEGIN\\n\" \\\n\t\"\treturn BIN_TO_UUID(b);\\n\" \\\n\t\"END\" % db,\n\n\t\"CREATE FUNCTION `%s`.`UUID_TO_BIN`(uuid CHAR(36))\\n\" \\\n\t\"RETURNS BINARY(16) DETERMINISTIC\\n\" \\\n\t\"BEGIN\\n\" \\\n\t\"\tRETURN UUID_TO_BIN(uuid);\\n\" \\\n\t\"END\" % db\n])\n```\n\n### MariaDB\n\nMariaDB does not provide UUID_TO_BIN and BIN_TO_UUID as it has its own uuid type\nwhich doesn't support the standard sql way of storing binary UUIDs. You can add\nthe functions to the database schema like so\n\n```python\nfrom rest_mysql.Record_MySQL import Commands\n\ndb = 'your_db_name'\nCommands.execute('primary', [\n\n\t\"CREATE FUNCTION `%s`.`BIN_TO_UUID`(b BINARY(16))\\n\" \\\n\t\"RETURNS CHAR(36) DETERMINISTIC\\n\" \\\n\t\"BEGIN\\n\" \\\n\t\"\tDECLARE hexStr CHAR(32);\\n\" \\\n\t\"\tSET hexStr = HEX(b);\\n\" \\\n\t\"\tRETURN LOWER(CONCAT(\" \\\n\t\t\t\"SUBSTR(hexStr, 1, 8), '-', \" \\\n\t\t\t\"SUBSTR(hexStr, 9, 4), '-', \" \\\n\t\t\t\"SUBSTR(hexStr, 13, 4), '-', \" \\\n\t\t\t\"SUBSTR(hexStr, 17, 4), '-', \" \\\n\t\t\t\"SUBSTR(hexStr, 21)\" \\\n\t\t\"));\\n\" \\\n\t\"END\" % db,\n\n\t\"CREATE FUNCTION `%s`.`UUID_TO_BIN`(uuid CHAR(36))\\n\" \\\n\t\"RETURNS BINARY(16) DETERMINISTIC\\n\" \\\n\t\"BEGIN\\n\" \\\n\t\t\"RETURN UNHEX(REPLACE(uuid, '-', ''));\\n\" \\\n\t\"END\" % db\n])\n```",
    "bugtrack_url": null,
    "license": null,
    "summary": "Stand alone version of Record_MySQL from Rest-OC to facilitate updating code to newer librairies. Has since been updated far beyond Rest-OC.",
    "version": "1.2.6",
    "project_urls": {
        "Source": "https://github.com/ouroboroscoding/rest_mysql",
        "Tracker": "https://github.com/ouroboroscoding/rest_mysql/issues"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5a9adc9ae52068a2c405de1816b37217605422bfd062ad9419bccaf7c3801725",
                "md5": "9d9784ae83f129be7cc0b445b444e226",
                "sha256": "15effe78477c7944898b11cb5a17e1633454a4990c58aa1736a12322f69745af"
            },
            "downloads": -1,
            "filename": "rest_mysql-1.2.6-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "9d9784ae83f129be7cc0b445b444e226",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 31766,
            "upload_time": "2025-09-02T16:47:11",
            "upload_time_iso_8601": "2025-09-02T16:47:11.501718Z",
            "url": "https://files.pythonhosted.org/packages/5a/9a/dc9ae52068a2c405de1816b37217605422bfd062ad9419bccaf7c3801725/rest_mysql-1.2.6-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0f22ba24462ae220f3046232d46e0a64f7e76a6167a41d5c2f754b67c964cb82",
                "md5": "a59ecf42351a006e5311a6fc895c3635",
                "sha256": "2a7d760f37085aaff6fcc5876dfd2194bc5da6ee3e3c4fceb6098a9183696340"
            },
            "downloads": -1,
            "filename": "rest_mysql-1.2.6.tar.gz",
            "has_sig": false,
            "md5_digest": "a59ecf42351a006e5311a6fc895c3635",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 31201,
            "upload_time": "2025-09-02T16:47:12",
            "upload_time_iso_8601": "2025-09-02T16:47:12.741431Z",
            "url": "https://files.pythonhosted.org/packages/0f/22/ba24462ae220f3046232d46e0a64f7e76a6167a41d5c2f754b67c964cb82/rest_mysql-1.2.6.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-02 16:47:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "ouroboroscoding",
    "github_project": "rest_mysql",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "arrow",
            "specs": [
                [
                    ">=",
                    "1.3.0"
                ],
                [
                    "<",
                    "1.4"
                ]
            ]
        },
        {
            "name": "config-oc",
            "specs": [
                [
                    ">=",
                    "1.1.0"
                ],
                [
                    "<",
                    "1.2"
                ]
            ]
        },
        {
            "name": "DBUtils",
            "specs": [
                [
                    "<",
                    "3.2"
                ],
                [
                    ">=",
                    "3.1.0"
                ]
            ]
        },
        {
            "name": "define-oc",
            "specs": [
                [
                    ">=",
                    "1.0.5"
                ],
                [
                    "<",
                    "1.1"
                ]
            ]
        },
        {
            "name": "json-fix",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ],
                [
                    "<",
                    "1.1"
                ]
            ]
        },
        {
            "name": "jsonb",
            "specs": [
                [
                    ">=",
                    "1.0.0"
                ],
                [
                    "<",
                    "1.1"
                ]
            ]
        },
        {
            "name": "PyMySQL",
            "specs": [
                [
                    ">=",
                    "1.1.1"
                ],
                [
                    "<",
                    "1.2"
                ]
            ]
        },
        {
            "name": "tools-oc",
            "specs": [
                [
                    "<",
                    "1.3"
                ],
                [
                    ">=",
                    "1.2.5"
                ]
            ]
        }
    ],
    "lcname": "rest-mysql"
}
        
Elapsed time: 2.09272s