python - Need to call a calculated variable & a dataframe object into a sql command....syntax error -
I have a date input in the parameter dictionary, after that, I have created a calculated date field outside the date input in the dictionary . Now, I want to use both date fields to create an SQL command, which I want to send in the Pandas dataframe for further calculation. Below is the paragraph code -
# Set parameters valueDict = {'Date': '2014-10-25'} # Fields calculated yr = pd.to_datetime (Dict ['date' ] - year - 1 mon = pd.Taw_tatime (dick ['date']) day of month = 01 calDattamp = sR (yr) + '-' + str (mon) + '-' + str (day) Pd.to_datetime (CalDateTemp) #create SQL command This is where I'm getting the error when trying to call the calculation field "CalDate". The error says - "Descriptor '__add__' requires 'datetime.datetime' object Is there le The table 1 where the X is obtained from "str" "cmd1 =" SELECT A, B, C, where X> = '"+ CalDate +"' and X & lt ('Table name', 'Table name', 'Table name' , CMD1, part, 'original'). MssqlToDataFrame ()
Please see I am going wrong with syntax.
This thing works
CMD1 = "Select A, B, C to Table 1 where X =>" + CalDateTemp + "'and RPDIVJ_D <='" + Ultimate Dict ['Date'] + "'"
Comments
Post a Comment