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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rest_mysql-1.3.3.tar.gz (32.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rest_mysql-1.3.3-py3-none-any.whl (33.5 kB view details)

Uploaded Python 3

File details

Details for the file rest_mysql-1.3.3.tar.gz.

File metadata

  • Download URL: rest_mysql-1.3.3.tar.gz
  • Upload date:
  • Size: 32.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for rest_mysql-1.3.3.tar.gz
Algorithm Hash digest
SHA256 7f2ff16cd5733c0cc16b21e6b34fb75a26bc747b3c7464ce95f822a952d3e175
MD5 999e4ae23998d12f55addbc36ada8a2d
BLAKE2b-256 ee9605e31b2fc000373580c371d22adc8ce51a0c1d9f5b6e387f2bd1f6c6989c

See more details on using hashes here.

File details

Details for the file rest_mysql-1.3.3-py3-none-any.whl.

File metadata

  • Download URL: rest_mysql-1.3.3-py3-none-any.whl
  • Upload date:
  • Size: 33.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for rest_mysql-1.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 59fdfe1e541af778d0c8d650fedee0a1083fb3b1c81818300ac076b3b65f19ea
MD5 7df18d1b4220341bf0ae712afe67d802
BLAKE2b-256 2ada0d009c51d55831670ce5f8373b54bd554bb42a400b934b49c0ade92aa319

See more details on using hashes here.

Release history Release notifications | RSS feed

1.3.4

2 files

This release

1.3.3 This release

2 files

1.3.2

2 files

1.3.1

2 files

1.3.0

2 files

1.2.7

2 files

1.2.6

2 files

1.2.5

2 files

1.2.4

2 files

1.2.3

1 file

1.2.2

1 file

1.2.1

1 file

1.2.0

1 file

1.1.5

1 file

1.1.4

1 file

1.1.3

1 file

1.1.2

1 file

1.1.1

1 file

1.1.0

1 file

1.0.3

1 file

1.0.2

1 file

1.0.1

1 file

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