1

Consider the ColdFusion query below:

<CFQUERY name="get_BillInfo" datasource="MJ_Escrutinio">
    Select BillNum, BillType, SpanDesc, EnglDesc, Conferencia, FortalezaRef, Equivalencia, FortalezaSuffix
    From dbo.LT_Bills
    Where BillID = #BillID#
</CFQUERY>

I'm having difficulties in running this query in Pycharm using a Microsoft SQL Server connector, is shows me the following error "Invalid column name 'BillID'", is there any possibility or translation on how to define the main cause of the problem?

rrk
  • 15,677
  • 4
  • 29
  • 45
  • Are you able to run it outside of PyCharm? If you add `TOP 1` after `Select` and remove `Where BillID = '#BillID#'` does the result have BillID? – Dan Roberts Dec 03 '19 at 18:39
  • 2
    Does the table even have a column called BillID? I wonder if you want `WHERE BillNum = #BillID#`. BTW: #BillID# is a ColdFusion construct. If you are converting this to Python, you will need a different syntax. – James A Mohler Dec 03 '19 at 18:55
  • @JamesAMohler Yes! That's basically want I'm looking for, do you have any references available for converting it into python code ? – Hector Maldonado Dec 03 '19 at 19:33
  • 1
    Try: https://stackoverflow.com/questions/1633332/how-to-put-parameterized-sql-query-into-variable-and-then-execute-in-python – James A Mohler Dec 03 '19 at 21:06
  • 1
    Also note that while converting this, make sure to eliminate the SQL Injection, – Shawn Dec 04 '19 at 16:15
  • @DanRoberts You'd have to add `BillID` into the `SELECT` for it to appear in the results. – Shawn Dec 04 '19 at 16:16
  • @Shawn yeah my comment meant to read to switch to `select *` as well – Dan Roberts Dec 04 '19 at 22:44
  • @DanRoberts Just don't forget to switch back to explicit columns after the test. I hear `SELECT *` can cause severe intestinal bleeding, chronic migraines and hair loss. :-) – Shawn Dec 05 '19 at 00:25

0 Answers0