-
Notifications
You must be signed in to change notification settings - Fork 369
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
Assignment operator << for multiline sql statements not working #79
Comments
Hi Databoy555, I had the same issue and I think I solved it. The code for this feature is in v0.3.9 which released fairly recently. Unfortunately, updating the package from python or anaconda only updates you to v0.3.8. If you don't want to wait for the release to your preferred package source, you may clone/install directly from the git repository. Hope this helps! |
BTW, this feature rocks! Thank you @catherinedevlin and @xiaochuanyu for everything. I use this package all the time. And now, with the assignment operator, it just became even more versatile. |
+1 I'm encountering the same problem, I'd love to have this feature fixed. |
@younglee23 . Thanks. I will perform a manual update over the next few days and confirm. Thanks for the awesome work |
I've installed v0.3.9 and I still get this error. Thanks! |
@esegal can u show the query u doing where this fails as well as the error output? |
cell 1: # Testing parameters with multiline sql
%load_ext sql
connection = 'postgresql://username:password@1.2.3.4/erezsegal'
from_clause = 'FROM my_table'
where_clause = '1=1' cell 2: %%sql $connection
SELECT * $from_clause WHERE $where_clause LIMIT 10; The error:
|
@esegal This issue pertains to storing result of a query into a variable, it doesn't apply to what you are trying to do. Expanding variables inside cell magic (
cell 2:
|
You're right, thanks, I was confused because of the duplicate issue thing with #80. |
Is this issue resolved now? |
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',)] |
If I understand the documentation correctly in order for me to store the query output to the variable "works" I can use "<<" as done below:
%%sql works << select top 10 itemid from tblitemdata
But this results in an error message
(pyodbc.ProgrammingError) ('42000', "[42000] [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Incorrect syntax near '<'. (102) (SQLExecDirectW)") [SQL: u'works <<\nselect top 10 itemid\nfrom tblitemdata']
Single line queries seem to get assigned fine i.e.
works = %sql select top 10 itemid from tblitemdata
returns "Done".
Thanks
The text was updated successfully, but these errors were encountered: