Skip to content
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

Update python examples #529

Merged
merged 3 commits into from
Apr 28, 2022
Merged

Update python examples #529

merged 3 commits into from
Apr 28, 2022

Conversation

Zhaars
Copy link
Contributor

@Zhaars Zhaars commented Apr 18, 2022

Actualizing python examples.

  • Updated encryptor_config_* with explicit table declaration to run with transparent encryption and be able to show type awareness functionality
  • Deleted zone_id field to be able to match zone from the query but not from the table.
  • Updated write_data function with explicit zone_id literal - deleted cast operator as it is not supported by Acra sql parser now.

Checklist

Update python example
@Zhaars Zhaars requested a review from Lagovas April 18, 2022 15:33
- column: data
data_type: bytes
# base64 bytes value
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mention decoded value of base64 string to understand what we should expect: "test-data"

@@ -25,16 +25,16 @@ def print_data(zone_id, connection):
console"""
result = connection.execute(
# explicitly pass zone id before related data
select([cast(zone_id.encode('utf-8'), BYTEA), test_table]))
select([literal_column("'{}'".format(zone_id)), test_table]))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about to avoid manual escaping values, use sqlalchemy's engine and specify type_ value for literal_column? I think that we can specify String type to apply escape rules for string values (according to TypeEngine documentation)?
if it will works, I prefer to use such approach. Because it will automatically work for mysql and all other DBs if we will add them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, let me check it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used sqlalchemy's literal, it performs escaping values inside. What do you think @Lagovas ?

Fixed after review
@Zhaars Zhaars requested a review from Lagovas April 19, 2022 10:50
Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm if it works with literal. I remember that had some problems with that. But probably it was related with compiling queries with bound values.

Copy link
Collaborator

@Lagovas Lagovas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

# Conflicts:
#	examples/python/encryptor_config_with_zone.yaml
@Zhaars Zhaars merged commit 1f2d55a into master Apr 28, 2022
Lagovas pushed a commit that referenced this pull request Apr 28, 2022
* zhars/update_python_examples

Update python examples
@Lagovas Lagovas deleted the zhars/update_python_examples branch May 19, 2022 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants