Код создаст пользовательский интерфейс и на основе ввода из пользовательского интерфейса выполнит некоторые вычисления и вернет несколько строк.однако он возвращает мне следующее:
DatabaseError: Ошибка выполнения на sql 'SELECT * FROM dbo.vw_DealPipelineHistorical WHERE InvestmentProgram =' CI - Основные кредитные вложения 'AND AND AND CashOutflowOrInflow =' Cash Inlow 'AND FundingCurrency =' CAD'AND DealStatus =' Funded '': ('42000', u "[42000] [Microsoft] [Драйвер ODBC SQL Server] [SQL Server] Неверный синтаксис рядом с ключевым словом 'AND'. (156) (SQLExecDirectW)") 127.0.0.1 - - [24 / Sep / 2019 17:31:27] "POST / _dash-update-component HTTP / 1.1" 500 -
def update_check(n_button, prog, progc, amnt, amntc, date, datec, inout, inoutc, curr, currc, given):
if given is None:
return "Please enter an initial probability.", "", ""
else:
filteroptions = (progc, amntc, datec, inoutc, currc)
filterstr =" WHERE ProbabilityofClosing = {}".format(given)
filterfundstr = ""
first = True
firstfund = True
outputlst = []
nofilter = "Filtering by: "
for option in filteroptions:
#skip iteration if not checked
if not option or option is None:
outputlst.append(None)
continue
outputlst.append(option)
#add WHERE or AND
if not firstfund:
filterstr += " AND "
filterfundstr += " AND "
else:
filterstr += " AND "
filterfundstr += " WHERE "
#add filters
if option[0] == 'prog':
if prog is None:
return "ERROR: Please select an Investment Program or adjust your filter criteria", "",""
continue
nofilter += "Investment Program, "
filterstr += "InvestmentProgram = '{}'".format(prog)
filterfundstr += "InvestmentProgram = '{}'".format(prog)
first = False
firstfund = False
elif option[0] == 'amnt':
if amnt is None:
return "ERROR: Please enter a Funding Amount or adjust your filter criteria", "", ""
continue
filterstr += "MostLikelyAmount = "
filterstr += str(amnt)
first = False
nofilter += "Amount, "
elif option[0] == 'date':
filterstr += "MostLikelyFundingDate = '{}'".format(date)
first = False
nofilter += "Date, "
elif option[0] == 'curr':
if not curr:
return "ERROR: Please select a Currency or adjust your filter criteria", "", ""
continue
if len(curr)>1:
filterstr += "("
filterfundstr += "("
firstcurr = True
for chosen in curr:
if firstcurr:
firstcurr = False
else:
filterstr += " OR "
filterfundstr += " OR "
filterstr += "FundingCurrency = '{}'".format(chosen)
filterfundstr += "FundingCurrency = '{}'".format(chosen)
filterstr += ")"
filterfundstr += ")"
else:
filterstr += "FundingCurrency = '{}'".format(curr[0])
filterfundstr += "FundingCurrency = '{}'".format(curr[0])
first = False
firstfund = False
nofilter += "Currency, "
elif option[0] == 'inout':
if inout is None:
return "ERROR: Please select a Flow Direction or adjust your filter criteria", "", ""
continue
filterstr += "CashOutflowOrInflow = '"
filterstr += inout + "'"
filterfundstr += "CashOutflowOrInflow = '{}'".format(inout)
first = False
firstfund = False
nofilter += "Flow Direction, "
if first:
nofilter = "No filters Selected."
else:
nofilter = nofilter[:-2]
#create query
filteredSQLPotential = "SELECT * FROM dbo.vw_DealPipelineHistorical " +filterstr
filteredSQLFunded = "SELECT * FROM dbo.vw_DealPipelineHistorical " +filterfundstr
completed, total = dataImport(filteredSQLPotential, filteredSQLFunded, first)
if total == 0:
return "No deals matched your search.", "Please update your search criteria and try again.", ""
confidence = "This update was calculated based on {} historical deals".format(total)
prob = get_updated_prob(given, completed, total)
return nofilter, prob*100, confidence
Я также хочу спросить, что означает опция?и вариант [0]?что это представляет в этом случае?Спасибо!