Hello, Only a question, at http://pypi.python.org/pypi/ibm_db/ there is a Python DBI driver for DB2. Why web2py is still using ODBC?? Will not be better to use this one instead of pyodbc??
Thanks On 11 mayo, 16:27, mdipierro <mdipie...@cs.depaul.edu> wrote: > Thank you. will look into it. > > Massimo > > On May 11, 6:31 am, Alexey Nezhdanov <snak...@gmail.com> wrote: > > > Hi. > > I've come across another subtle problem with web2py's DAL running over IBM > >DB2database. > >DB2requires the left table to immidiatedly preceed the 'left outer join' > > keyword. > > IOW: > > select * from a, b left outer join c on c.a_id=a.id > > is incorrect. Correct form is: > > select * from b, a left outer join c on c.a_id=a.id > > it looks moronish enough, but alas, we have to live with it. > > > I have modified my local copy of web2py to satisfy this requirement. > > Please note that this sample can not be copypasted into web2py's sql.py as > > is because of full_table_name wrapper that I added to solve another problem > > - schemas support. But replacing 'full_table_name(db, t)' with just 't' > > should work just fine. > > > join = attributes['left'] > > command = self._db._translator['left join'] > > if not isinstance(join, (tuple, list)): > > join = [join] > > joint = [t._tablename for t in join if not isinstance(t, > > SQLJoin)] > > joinon = [t for t in join if isinstance(t, SQLJoin)] > > tables_to_merge={} > > > [tables_to_merge.update(dict.fromkeys(parse_tablenames(str(t.query)))) for t > > in joinon] > > joinont = [t.table._tablename for t in joinon] > > [tables_to_merge.pop(t) for t in joinont if t in > > tables_to_merge] > > important_tablenames = joint + joinont + tables_to_merge.keys() > > excluded = [t for t in tablenames if not t in > > important_tablenames ] > > sql_t = ', '.join([full_table_name(self._db, t) for t in > > excluded + tables_to_merge.keys()]) > > if joint: > > sql_t += ' %s %s' % (command, ', > > '.join([full_table_name(self._db, t) for t in joint])) > > for t in joinon: > > sql_t += ' %s %s' % (command, str(t)) > > > Regards > > Alexey