我在同一类中有3个静态方法,并且有一种情况需要将其中两个设置的变量调用为第3个方法。 (版本-Python 3.6) 请提出建议。
import datetime
class Topclass:
@staticmethod
def main_func():
today = datetime.date.today()
date_string = str(today.year)+"-"+str(today.month)+"-"+str(today.day)
@staticmethod
def checkvalue():
try:
conn = pyodbc.connect('DRIVER={SQL Server};SERVER=test.database.windows.net,1433',database='testdb',user='fa',password='sampletest1234')
query = "SELECT people, COUNT(people) as summation FROM dbo.dim_productinformation GROUP by valuecount"
data = pd.read_sql(query,conn)
except:
raise
@staticmethod
def tableupdate():
#here I would like to call the 'date_string' variable from main_func() and 'data' from checkvalue()
我想获取每个变量的内容,然后通过tableupdate()方法将其插入到SQL DB中。