Closed kamal-1 closed 4 years ago
Yes, of course.
q = "select name, val from {sn!i}.{tn!i}"
p = { "sn": "ETL", "tn": "METADATA" }
print(c.format.format(q, **p))
Reference for format() function: https://github.com/badoo/pyexasol/blob/master/docs/REFERENCE.md#format
General information about Exasols-specific formatting: https://github.com/badoo/pyexasol/blob/master/docs/SQL_FORMATTING.md
Enjoy!
Please note, the better way to specify schema for identifier is to use tuple.
q = "select name, val from {table!i}"
p = {"table": ("ETL", "METADATA")}
print(c.format.format(q, **p))
Result:
select name, val from ETL.METADATA
Please note, the better way to specify schema for identifier is to use tuple.
q = "select name, val from {table!i}" p = {"table": ("ETL", "METADATA")} print(c.format.format(q, **p))
Result:
select name, val from ETL.METADATA
Awesome. Thanks for the quick response. I'll update the code based on you recommendation of using the tuple.
We can get the query text after the query has executed.
q = "select name, val from {sn!i}.{tn!i}" p = { "sn": "ETL", "tn": "METADATA" } c.execute(q, p).fetchall() c.last_statement().query
Is there a way to get the query text substituted with the parameter values before the query execution?