From d1e378d028dfe282b1c4d71b6f4b9344caa50c23 Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Wed, 10 Feb 2021 19:50:27 -0800 Subject: [PATCH 1/2] remove mysql-connector-python --- Pipfile | 1 - Pipfile.lock | 54 +--------------------------------------------------- 2 files changed, 1 insertion(+), 54 deletions(-) diff --git a/Pipfile b/Pipfile index 9bfc5d0..9aa1a6b 100644 --- a/Pipfile +++ b/Pipfile @@ -18,7 +18,6 @@ flask-sqlalchemy = "~=2.4.1" marshmallow-sqlalchemy = "~=0.23" apispec = "~=3.3.0" apispec-webframeworks = "~=0.5.2" -mysql-connector-python = "8.0.12" python-jose = "*" [requires] diff --git a/Pipfile.lock b/Pipfile.lock index 6b7ae6c..f3d9312 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "3dbd4f805e11223de7a5d4e40c5266d4e0560004e9f52a58c2b5294197844eab" + "sha256": "a7338ce148831d5a7dd43a147441bf957fd34c48e5038ba8337946b4869f5353" }, "pipfile-spec": 6, "requires": { @@ -226,58 +226,6 @@ ], "version": "==0.8.4" }, - "mysql-connector-python": { - "hashes": [ - "sha256:0f41b3142fe5325e830a3420915a6cf652b9da1d3a8e0df11bade1c120c0fc2c", - "sha256:114ab771b6a1a98ea1e2e88c44fcf3ff713c65ac9fa8d3e88c0034e1fc0aed5d", - "sha256:2184f6b86c3981e5b2ffa82e946f12368a5f1758f022d9a30f43077950136114", - "sha256:2833d47ad04d08c1d3ab64b3b2b9203f84333f3463ca99332961c0ae1bf8101f", - "sha256:2eabe3f8a264efb3af04cb477943a8c8f04396fda0c5e2ad3450f9c044ddc603", - "sha256:2ed23de6c0a9e5769fc14f2930492b81629cb40f79381d79c679ddd04d5f3ddb", - "sha256:320a5929a39cae75a1cf0603b3baffdd7f36a0e520bfdd471d456f70973fc0ac", - "sha256:451120a964d3c56d983c7664f7c799bd92d5660085e3d8058defdec3e8a3b93a", - "sha256:49394f30e792a880ca2bd6e7e9d11eb86df0c316ab629b6d19185c9f5ca0811d", - "sha256:5e84dcc25d4b505118e0c28f07de496a41bc0ab121232a2aba83d0248cd49257", - "sha256:76758ee1d57b712bfbdae358506d578b955fda9dd91ae068a59e0fe02138ef0d", - "sha256:7b7fa9ed17a43164df2e203b25bf71f8679460795c055fb23f64a66f7ecde6be", - "sha256:7d55a446700bec300ec6a5b928b4700384bc2add43fa3b9ca124b03640db4e19", - "sha256:a37dff9d748d92134ea47ddbaafdfadb7f3bf9c8a66429ae247fb1ccaf6f7337", - "sha256:a5bf1979c126f475bc10c840d9464d5a2e4604bdc67b6be8bbaf9dbc4a3d8b89", - "sha256:a63658c518502736979dc1a79250c5e54ebbbd5ccfe9ec040cc591fcefbf1974", - "sha256:aa2307ddc30dd20dbca1165ffb1cf41dcf30ae1bcf46e74cb92c06a0eeeb0aac", - "sha256:c783e1dc8b78a1b1a9ebbf3ccb12d17e4513d91fafeb5b6c06a29f2d5619e285", - "sha256:dd7ed6baa35c3a89c6c8c8d6be0ebe1b089e77f41bb874b9dc4bc6db83ad654f", - "sha256:eb5d409df6e54c9a8f47dc901334d5e8b30a7967775d6eb3158494bf0534995d", - "sha256:efe72ce5e9d9051aeb99a4910949b3afb17570106a980a7a4f480d3894b1f426", - "sha256:f42516ef6b80ce70322f1fda63a8762f898df60df8ba621b2308d933216a8598", - "sha256:faf2aeb18725bb8bb6aae1e33b358d328cd35ded1b610d4c8608529b3051f634" - ], - "index": "pypi", - "version": "==8.0.23" - }, - "protobuf": { - "hashes": [ - "sha256:0e247612fadda953047f53301a7b0407cb0c3cb4ae25a6fde661597a04039b3c", - "sha256:0fc96785262042e4863b3f3b5c429d4636f10d90061e1840fce1baaf59b1a836", - "sha256:1c51fda1bbc9634246e7be6016d860be01747354ed7015ebe38acf4452f470d2", - "sha256:1d63eb389347293d8915fb47bee0951c7b5dab522a4a60118b9a18f33e21f8ce", - "sha256:22bcd2e284b3b1d969c12e84dc9b9a71701ec82d8ce975fdda19712e1cfd4e00", - "sha256:2a7e2fe101a7ace75e9327b9c946d247749e564a267b0515cf41dfe450b69bac", - "sha256:43b554b9e73a07ba84ed6cf25db0ff88b1e06be610b37656e292e3cbb5437472", - "sha256:4b74301b30513b1a7494d3055d95c714b560fbb630d8fb9956b6f27992c9f980", - "sha256:4e75105c9dfe13719b7293f75bd53033108f4ba03d44e71db0ec2a0e8401eafd", - "sha256:5b7a637212cc9b2bcf85dd828b1178d19efdf74dbfe1ddf8cd1b8e01fdaaa7f5", - "sha256:5e9806a43232a1fa0c9cf5da8dc06f6910d53e4390be1fa06f06454d888a9142", - "sha256:629b03fd3caae7f815b0c66b41273f6b1900a579e2ccb41ef4493a4f5fb84f3a", - "sha256:72230ed56f026dd664c21d73c5db73ebba50d924d7ba6b7c0d81a121e390406e", - "sha256:86a75477addde4918e9a1904e5c6af8d7b691f2a3f65587d73b16100fbe4c3b2", - "sha256:8971c421dbd7aad930c9bd2694122f332350b6ccb5202a8b7b06f3f1a5c41ed5", - "sha256:9616f0b65a30851e62f1713336c931fcd32c057202b7ff2cfbfca0fc7d5e3043", - "sha256:b0d5d35faeb07e22a1ddf8dce620860c8fe145426c02d1a0ae2688c6e8ede36d", - "sha256:ecc33531a213eee22ad60e0e2aaea6c8ba0021f0cce35dbf0ab03dee6e2a23a1" - ], - "version": "==3.14.0" - }, "pyasn1": { "hashes": [ "sha256:014c0e9976956a08139dc0712ae195324a75e142284d5f87f1a87ee1b068a359", From e8e01cf5edf56f4505feaf37f9698309bdcf8e8b Mon Sep 17 00:00:00 2001 From: Adrian Edwards <17362949+MoralCode@users.noreply.github.com> Date: Sat, 24 Apr 2021 22:35:24 -0700 Subject: [PATCH 2/2] WIP from attempting to make sqlite work --- common/guid.py | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/common/guid.py b/common/guid.py index ed95e8b..f8511d5 100644 --- a/common/guid.py +++ b/common/guid.py @@ -1,30 +1,43 @@ -from __future__ import absolute_import +######################## +# UUID for SQLite hack # +######################## + +from sqlalchemy.types import TypeDecorator, BINARY, CHAR +from sqlalchemy.dialects.postgresql import UUID import uuid -from sqlalchemy import types, func -#https://docs.sqlalchemy.org/en/13/core/custom_types.html#backend-agnostic-guid-type -class HashColumn(types.TypeDecorator): - impl=types.CHAR + +class HashColumn(TypeDecorator): + """Platform-independent GUID type. + Uses PostgreSQL's UUID type, otherwise uses + CHAR(32), storing as stringified hex values. + """ + impl = BINARY def load_dialect_impl(self, dialect): if dialect.name == 'postgresql': return dialect.type_descriptor(UUID()) else: - return dialect.type_descriptor(types.BINARY(16)) + return dialect.type_descriptor(BINARY(16)) def process_bind_param(self, value, dialect): if value is None: return value + # elif dialect.name == 'postgresql': + # return str(value) else: - return uuid.UUID(hex=value).bytes + if not isinstance(value, uuid.UUID): + return uuid.UUID(hex=value).bytes + else: + return value.bytes def process_result_value(self, value, dialect): + print(value) if value is None: return value else: - return uuid.UUID(bytes=value).hex - - # This is a shallow copy and is provided to fulfill part of the TypeEngine contract. It usually does not need to be overridden unless the user-defined TypeDecorator has local state that should be deep-copied. - # def copy(self, **kw): - # return HashColumn(32) \ No newline at end of file + if not isinstance(value, uuid.UUID): + + value = uuid.UUID(bytes=value) + return value \ No newline at end of file