如何在Python中存储过程中解析可变值

发布于 2025-02-04 13:38:07 字数 1823 浏览 2 评论 0原文

我需要使用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)

enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉态萌生 2025-02-11 13:38:07

我不确定您的要求,但是我想您正在问如何调用存储过程?可以在 and在 samples 。在您的情况下,您应该能够做这样的事情:

cursor.callproc("CORE_VALUATIONS.VALUATIONS.INSERTEQCLOSINGPRICE",
                ("SGEPSBSH", datetime.date(2022, 6, 1), "1110.9852",
                 None, None))

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:

cursor.callproc("CORE_VALUATIONS.VALUATIONS.INSERTEQCLOSINGPRICE",
                ("SGEPSBSH", datetime.date(2022, 6, 1), "1110.9852",
                 None, None))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文