Skip to main content

rest_mysql

pypi version MIT License

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 for changes from release to release.

Full Documentation

Install

Requires

rest_mysql requires python 3.10 or higher

Install via pip

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:

from RestOC import Record_MySQL
from RestOC.Record_MySQL import db_create, Record
from RestOC.Record_Base import register_type

New:

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 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

from rest_mysql.Record_MySQL import Commands

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

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

	"CREATE FUNCTION `%s`.`UUID_TO_BIN`(uuid CHAR(36)) "
	"RETURNS BINARY(16) DETERMINISTIC "
	"BEGIN "
	"	RETURN UUID_TO_BIN(uuid); "
	"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

from rest_mysql.Record_MySQL import Commands

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

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

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

Metadata

Release files for rest-mysql 1.3.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rest-mysql 1.3.7
File Size Uploaded Provenance Actions
rest_mysql-1.3.7.tar.gz 33.8 kB Without provenance Details for rest_mysql-1.3.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for rest-mysql 1.3.7
File Interpreter ABI Platform Actions
rest_mysql-1.3.7-py3-none-any.whl Python 3 none any Details for rest_mysql-1.3.7-py3-none-any.whl

Total release size: 68.1 kB

Release files / rest_mysql-1.3.7.tar.gz

Download URL rest_mysql-1.3.7.tar.gz
Size 33.8 kB
Tags Source
SHA-256 checksum
How to use checksums
65c82dc1a5f70958bd19996cf7db9502232afbaac83b8d4ec0a593bc1230309e
BLAKE2b-256 checksum
How to use checksums
4f7cb83ab861d2847f90557069b86efd557febb0a2d31a194b3a42919da8f653
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / rest_mysql-1.3.7-py3-none-any.whl

Download URL rest_mysql-1.3.7-py3-none-any.whl
Size 34.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3734af334f9e0933a217743a2b50f1c7351e33c34d4a1006c62cbe83cff0e3a9
BLAKE2b-256 checksum
How to use checksums
715e55f2b70df3754a177b38841e902b13363c03e6484413934b16f5d07cdbed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for rest-mysql 1.3.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page