|
Python Connector for Snowflake Querying data - Python Connector for Snowflake |
|
Once connected, you can execute SQL queries to retrieve data from your Snowflake database.
cursor object using the cursor() connection method.
my_cursor = my_connection.cursor()
execute() cursor method.
my_cursor.execute("SELECT * FROM employees")
fetch*() methods.
for row in my_cursor.fetchall():
print(row)
You can use parameterized queries to pass variable values to your SQL statements. This allows you to reuse the same query with different data and helps to prevent SQL injection attacks.
Pass parameters as a list or tuple to the execute() method:
for row in my_cursor.fetchall():
print(row)
Each placeholder ? in the query is replaced with a corresponding value from the parameter list.