{"id":480,"date":"2024-10-25T11:12:13","date_gmt":"2024-10-25T11:12:13","guid":{"rendered":"https:\/\/datadandies.nl\/?p=480"},"modified":"2024-10-25T11:12:13","modified_gmt":"2024-10-25T11:12:13","slug":"using-sql-queries-in-a-python-worksheet-in-snowflake","status":"publish","type":"post","link":"https:\/\/datadandies.nl\/index.php\/2024\/10\/25\/using-sql-queries-in-a-python-worksheet-in-snowflake\/","title":{"rendered":"Using SQL queries in a python worksheet in Snowflake"},"content":{"rendered":"\n<p>Did you know you can use SQL queries in your Python worksheets in Snowflake? This works as follows:<\/p>\n\n\n\n<p>dataframe = session.sql( &#8221;&#8217; YOUR SQL QUERY GOES HERE &#8221;&#8217; )<\/p>\n\n\n\n<p>And voila! Don\u2019t forget to return it in the function in the worksheet if you wish to inspect the resulting dataframe in the results pane.<\/p>\n\n\n\n<p>I have used this recently in a stored procedure. The goal of the stored procedure was to check if certain categories from Table_A existed in Table_B and if not, send an email detailing the categories that had to be added to Table_B. Very useful stuff.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Did you know you can use SQL queries in your Python worksheets in Snowflake? This works as follows: dataframe = session.sql( &#8221;&#8217; YOUR SQL QUERY GOES HERE &#8221;&#8217; ) And voila! Don\u2019t forget to return it in the function in the worksheet if you wish to inspect the resulting dataframe in the results pane. I&hellip;<\/p>\n<p class=\"more-link\"><a href=\"https:\/\/datadandies.nl\/index.php\/2024\/10\/25\/using-sql-queries-in-a-python-worksheet-in-snowflake\/\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[37,40,4],"class_list":["post-480","post","type-post","status-publish","format-standard","hentry","category-blog","tag-python","tag-snowflake","tag-sql"],"_links":{"self":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/480","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/comments?post=480"}],"version-history":[{"count":1,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/480\/revisions"}],"predecessor-version":[{"id":481,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/posts\/480\/revisions\/481"}],"wp:attachment":[{"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/media?parent=480"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/categories?post=480"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/datadandies.nl\/index.php\/wp-json\/wp\/v2\/tags?post=480"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}