如何在Python中存储过程中解析可变值
我需要使用Python在存储过程中解析变量值时,以下是存储过程
=“ call core_valuations.valuations.valuations.inserteqclosingprice(“ sgepsbsh ”,to_date(to_date) 2022-06-01 ,“ ddmmmyyyy”)&','ddmonyyyy'),“ 1110.9852 ”,null,null,null);”
import pandas as pd
import win32com.client
import re
import os
import pandas
import datetime as dt
from datetime import date
EMAIL_ACCOUNT = 'robin.hood'
EMAIL_SUBJ_SEARCH_STRING = 'SGEPSBSH Index Level'
EMAIL_CONTNT = {'Ticker': [], 'TickerLevel': [], 'DATE': []}
out_app = win32com.client.gencache.EnsureDispatch("Outlook.Application")
out_namespace = out_app.GetNamespace("MAPI")
#lastWeekDateTime = dt.datetime.now() - dt.timedelta(days=1)
#lastWeekDateTime = lastWeekDateTime.strftime('%m/%d/%Y %H:%M %p')
root_folder = out_namespace.GetDefaultFolder(6)
out_iter_folder = root_folder.Folders['Email_Snapper']
#out_iter_folder = out_iter_folder.Restrict("[ReceivedTime] >= '" + lastWeekDateTime + "'")
item_count = out_iter_folder.Items.Count
Flag = False
cnt = 1
if item_count > 0:
for i in range(item_count, 0, -1):
message = out_iter_folder.Items[i]
if EMAIL_SUBJ_SEARCH_STRING in message.Subject and cnt <=1:
cnt=cnt+1
Body_content = message.Body
Body_content = Body_content[:Body_content.find("Regards")].strip()
df = pd.DataFrame([Body_content])
print(df.to_string())
Ticker = df.to_string()[-82:-74]
print(Ticker)
price = df.to_string()[-8:]
print(price)
Date = df.to_string()[-21:-11]
print(Date)
I need some help in parsing variable value in stored procedure using python, below is the stored procedure
="call CORE_VALUATIONS.VALUATIONS.INSERTEQCLOSINGPRICE("SGEPSBSH",to_date('"&TEXT(2022-06-01,"DDMMMYYYY")&"','ddmonyyyy'),"1110.9852",NULL,NULL);"
import pandas as pd
import win32com.client
import re
import os
import pandas
import datetime as dt
from datetime import date
EMAIL_ACCOUNT = 'robin.hood'
EMAIL_SUBJ_SEARCH_STRING = 'SGEPSBSH Index Level'
EMAIL_CONTNT = {'Ticker': [], 'TickerLevel': [], 'DATE': []}
out_app = win32com.client.gencache.EnsureDispatch("Outlook.Application")
out_namespace = out_app.GetNamespace("MAPI")
#lastWeekDateTime = dt.datetime.now() - dt.timedelta(days=1)
#lastWeekDateTime = lastWeekDateTime.strftime('%m/%d/%Y %H:%M %p')
root_folder = out_namespace.GetDefaultFolder(6)
out_iter_folder = root_folder.Folders['Email_Snapper']
#out_iter_folder = out_iter_folder.Restrict("[ReceivedTime] >= '" + lastWeekDateTime + "'")
item_count = out_iter_folder.Items.Count
Flag = False
cnt = 1
if item_count > 0:
for i in range(item_count, 0, -1):
message = out_iter_folder.Items[i]
if EMAIL_SUBJ_SEARCH_STRING in message.Subject and cnt <=1:
cnt=cnt+1
Body_content = message.Body
Body_content = Body_content[:Body_content.find("Regards")].strip()
df = pd.DataFrame([Body_content])
print(df.to_string())
Ticker = df.to_string()[-82:-74]
print(Ticker)
price = df.to_string()[-8:]
print(price)
Date = df.to_string()[-21:-11]
print(Date)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不确定您的要求,但是我想您正在问如何调用存储过程?可以在 and在 samples 。在您的情况下,您应该能够做这样的事情:
I'm not sure exactly what you are asking for, but I think you are asking about how to call a stored procedure? This can be found in the documentation and in the samples. In your case you should be able to do something like this: