-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Types: Add support for BINARY columns and improve support for FLOATs #12
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind that CrateDB also supports BitString type, but I don't think that's what we want here, right?
Right. Here, it is about providing an emulation for a BLOB-type column. However, expanding type support to include the |
def bind_processor(self, dialect): | ||
if dialect.dbapi is None: | ||
return None | ||
|
||
# TODO: DBAPIBinary = dialect.dbapi.Binary | ||
|
||
def process(value): | ||
if value is not None: | ||
# TODO: return DBAPIBinary(value) | ||
return base64.b64encode(value).decode() | ||
else: | ||
return None | ||
|
||
return process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self, or others who want to pick this up:
Review that detail about returning a DBAPIBinary
, or not.
# Python 3 has native bytes() type | ||
# both sqlite3 and pg8000 seem to return it, | ||
# psycopg2 as of 2.5 returns 'memoryview' | ||
def result_processor(self, dialect, coltype): | ||
if dialect.returns_native_bytes: | ||
return None | ||
|
||
def process(value): | ||
if value is not None: | ||
return base64.b64decode(value) | ||
return value | ||
|
||
return process |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to self, or others who want to pick this up:
Review that detail about dialect.returns_native_bytes
: Should it be handled differently, because, well, base64.b64decode
actually returns native bytes already?
9941c5d
to
2a34862
Compare
2f08b2a
to
43c45fb
Compare
6ac0a22
to
d2c7613
Compare
bde4bcb
to
8f01308
Compare
About
Improvements to be mainlined from https://github.com/pyveci/supertask/blob/19316e2/supertask/store/cratedb.py. The support for binary data types is being emulated by serializing them to STRING using base64. In that way, pickled data can be stored and retrieved without further ado.
Backlog