英文:
store values from snowflake table into variable in python
问题
我需要从Snowflake表中获取值,并使用Python将其存储到变量中。
之后,我需要将该值与文件名(product_yyyymmdd.csv)合并。
以下是我的代码:
HA_file_path = '''select CONFIG_VALUE from CONFIGURATIONS where CONFIG_NAME ='HA' '''
file_path = cs.execute(HA_file_path)
它没有返回任何值,而是打印了类似于以下内容:
snowflake.connector.cursor.SnowflakeCursor object at 0x7fefbe68a070
有任何帮助吗?
英文:
i need to get value from snowflake table and store into variable using python.
after that i need to merge that value with file name(product_yyyymmdd.csv).
below is my code
HA_file_path = ''' select CONFIG_VALUE from CONFIGURATIONS where CONFIG_NAME =\ 'HA''''
-- syntax is correct
file_path = cs.execute(HA_file_path)
its not returning any value and printing something like this :
snowflake.connector.cursor.SnowflakeCursor object at 0x7fefbe68a070
any help!
答案1
得分: 0
在这一行中:file_path = cs.execute(HA_file_path)
,你将一个变量分配给了游标对象,但你没有获取结果。如果你想将表中的一个值存储为变量,你可以在execute
之后使用fetchone
方法:
cs.execute(HA_file_path)
file_path = cs.fetchone()[0]
print(file_path)
英文:
In the line: file_path = cs.execute(HA_file_path)
you assigned a variable to the cursor object, but you are not fetching results. If you want to store just one value from the table as a variable, you can use fetchone
method after execute
:
cs.execute(HA_file_path)
file_path = cs.fetchone()[0]
print(file_path)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论