-
Notifications
You must be signed in to change notification settings - Fork 320
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
How to get the original SQL query from the "sql"/"query" field which is in json format #102
Comments
same question |
1 similar comment
same question |
You could add following code into the Query class and provide the types to get the correct query. E.g: class Query
...
def to_query(self, types):
if self.agg_ops[self.agg_index]:
rep = 'SELECT {agg} ({sel}) FROM table'.format(
agg=self.agg_ops[self.agg_index],
sel='col{}'.format(self.sel_index),
)
else:
rep = f'SELECT col{self.sel_index} FROM table'
if self.conditions:
cond_strings = []
for i, o, v in self.conditions:
if types[i] == "text":
cond_strings.append(f"col{i} {self.cond_ops[o]} '{v}'")
else:
cond_strings.append(f"col{i} {self.cond_ops[o]} {v}")
rep += ' WHERE ' + ' AND '.join(cond_strings)
return rep
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How can I convert the following code in "sql" field into the original SQL query
I tried using
lib.query.Query.from_dict
method but getSELECT col5 FROM table WHERE col3 = SOUTH AUSTRALIA
and tried using
lib.dbengine.DBEngine.execute_query
method but getSELECT col5 AS result FROM table_1_1000181_1 WHERE col3 = :col3
.None of the above two methods get the correct SQL query, so how can I get it? Anybody help?
The text was updated successfully, but these errors were encountered: