[英]Defining Python function with input
I have Postgres table called Records with several appIds. 我有一个名为Records的Postgres表,有多个appIds。 I am writing a function to pull out the data for one
AppId
(ABC0123) and want to store this result in dataframe df
. 我正在编写一个函数来提取一个
AppId
(ABC0123)的数据,并希望将此结果存储在dataframe df
。 I have created a variable AppId1 to store my AppId(ABC0123) and passed it to the query. 我创建了一个变量AppId1来存储我的AppId(ABC0123)并将其传递给查询。 The script got executed, but it did not create the dataframe.
脚本已执行,但它没有创建数据帧。
def fun(AppId):
AppId1=pd.read_sql_query(""" select "AppId" from "Records" where "AppId"='%s'""" %AppId,con=engine )
query = """" SELECT AppId from "Records" where AppId='%s' """ % AppId1
df=pd.read_sql_query(query,con=engine)
return fun
fun('ABC0123')
def fun(AppId):
AppId1=pd.read_sql_query(""" select 'AppId' from 'Records' where 'AppId'='%s'""" %AppId,con=engine )
query = """ SELECT 'AppId' from 'Records' where AppId='%s' """ %AppId
df=pd.read_sql_query(query,con=engine)
return df
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.