exasol / pyexasol

Exasol Python driver with low overhead, fast HTTP transport and compression
MIT License
72 stars 39 forks source link

Add comments to queries #63

Closed smaspe closed 3 years ago

smaspe commented 3 years ago

For purposes of auditing and profiling, I would like to add comments to some queries.

(For clarity, this type of comments: https://docs.exasol.com/sql_references/basiclanguageelements.htm#Comments_in_SQL)

For cases where the query is directly executed, like when running connection.execute("SELECT * FROM FOO"), this is easy.

However, for import_* and export_* function, as well as for metadata access functions, the actual query is built in pyexasol, without possibility for us to add comments to it.

Is that something that you'd be willing to integrate in pyexasol? If so, I'd be willing to help

littleK0i commented 3 years ago

Yep, it should be easy to implement using import_params and export_params.

Do you prefer to have comment in the beginning, at the end or somewhere in the middle of query? :)

smaspe commented 3 years ago

beginning is fine :)

So, for import, you'd recommend adding a key to import_params and use it here: https://github.com/badoo/pyexasol/blob/da486a18313d3cd4b40280ade66f5f21b0c2f120/pyexasol/http_transport.py#L161

for export, use the same idea here: https://github.com/badoo/pyexasol/blob/da486a18313d3cd4b40280ade66f5f21b0c2f120/pyexasol/http_transport.py#L105

And add a bit of documentation here: https://github.com/badoo/pyexasol/blob/da486a18313d3cd4b40280ade66f5f21b0c2f120/docs/HTTP_TRANSPORT.md#parameters

Would that be sufficient?

littleK0i commented 3 years ago
  1. Extra argument comment for export_params, import_params.
  2. Additional condition in query builders for EXPORT and IMPORT to use the extra argument.
  3. Validation, to make sure comment will not contain \n, */ or other ways for SQL injection.
  4. Documentation.
  5. A few lines in http_transport examples.

Thank you.

littleK0i commented 3 years ago

Live in 0.16.1. Enjoy! :)

smaspe commented 3 years ago

That was fast! thanks :)