Py学习  »  Python

Python中的SQL查询-在SQL查询中插入Python中的值

Starbucks • 2 年前 • 1338 次点击  

我有一个python中的SQL查询,它根据时间戳过滤,但是时间戳根据数据帧中的值而变化。

query = """(SELECT [ID],[Timestamp],[Value] FROM [table] Where [Timestamp] >= '2021-10-13') alias"""

big_df = spark.read.format("jdbc").option("driver", driver).option("url", url).option("dbtable", query).load()

print(somedf.Timestamp.min())
'2021-01-01'

query = """(SELECT [ID],[Timestamp],[Value] FROM [table] Where [Timestamp] >= somedf.Timestamp.min()) alias"""

很明显,顶线行不通

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/137820
 
1338 次点击  
文章 [ 2 ]  |  最新文章 2 年前