-
Notifications
You must be signed in to change notification settings - Fork 371
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
Unable to use variables in multiline statements (%%sql) #80
Comments
This is a duplicate of #79. @catherinedevlin is preparing this as a new feature for the 0.3.9 release You can upgrade your installation by cloning the repository and I upgraded and its working great so thanks to the team for working on it. Also, see news.txt file for more details on 0.3.9 |
As these are different issues I can confirm that v0.3.9 doesn't solve this issue. Hope it will be solved soon! |
Status on this? |
This problem has been resolved in 0.3.9 Just use For multiline SQL name = 'Countess'
%%sql
select description
from character
where charname = :name
# output: [(u'mother to Bertram',)] You can also use name = 'Countess'
%sql select description from character where charname = :name
# output: [(u'mother to Bertram',)] |
Using IE part_of_query = "where sign_in_count > 10" %sql select count(name) from users $part_of_query works with |
Thank you for your intuition! |
In my case both I have the following code:
OR
How I am supposed to use my python variable inside a query passed to |
I made a PR for this, and I think it should resolve your issue @mrjoseph84 . Try: db_table = "my_schema.my_table"
%%sql
CREATE TABLE {db_table} AS
SELECT x, CAST (y AS INT) as duration
FROM abc.def |
Thanks a lot - this worked for me as expected :) |
Awesome! Glad to hear it :) |
* Moved integrations into a section + added mindsdb * Fixing toc issue * Editing guide * Review fixes * Skip execution + ipynb format
This reverts commit 16bd4e6.
Variables can be used normally with the following syntax:
[1] table = 'my_fancy_table'
[2] %sql SELECT * FROM $table
Unfortunately, when I want to create multiline sql statements (like the following) variables are not possible to use:
[1] table = 'my_fancy_table'
[2] %%sql SELECT name, firstname FROM $table
Outputs:
(psycopg2.ProgrammingError) syntax error at or near "$"
LINE 1: SELECT * FROM $table;
Does I have to use a different variables syntax for multiline statements or do multiline statements simply not support variables?
Thanks in advance.
The text was updated successfully, but these errors were encountered: