At this point we do not support table names and field names that are
keywords in SQL. In fact the DAL has a parameter
DAL(..., check_reserved=True)
that will check for you and will prevent you from using the field name
"order". The check is normally disabled for speed.
On Wednesday, 18 April 2012 10:47:07 UTC-5, Khalil KHAMLICHI wrote:
>
> looks like its a DAL issue,
>
> The DAL need to include the [ ] by default around column names, I also
> tested using " " around the columns and it works too.
>
> Hopefully Massimo you will look at this, in the meantime I will try to
> hack my way in the source files.
>
> here is a code I tested outside w2p :
>
> con = pyodbc.connect('DRIVER={SQL
> Server};SERVER=chi-c7269ceba93\\SQLEXPRESS;DATABASE=SambaData2;UID=sa;PWD=sambapos.1234')
> cur = con.cursor()
>
> >>> x = cur.execute('select * from MenuItems')
>
> >>> x = cur.execute('select Id, Order from ScreenMenuCategories')
> Traceback (most recent call last):
> File "<pyshell#15>", line 1, in <module>
> x = cur.execute('select Id, Order from ScreenMenuCategories')
> ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server
> Driver][SQL Server]Incorrect syntax near the keyword 'Order'. (156)
> (SQLExecDirectW)")
>
> >>> x = cur.execute('select "Id", "Order" from ScreenMenuCategories')
> >>> for i in x:
> print i
>
> (1, 0)
> (2, 0)
> (3, 0)
> (4, 0)
> (5, 0)
> (6, 0)
> (7, 0)
>
> >>> x = cur.execute('select Id, [Order] from ScreenMenuCategories')
> >>> for i in x:
> print i
>
> (1, 0)
> (2, 0)
> (3, 0)
> (4, 0)
> (5, 0)
> (6, 0)
> (7, 0)
>
>