On Mar 30, 4:09 am, Jason Lotz <jayl...@gmail.com> wrote:
> I'm sorry if I am repeating an existing discussion. I searched and
> found similar issues but nothing that helped.
>
> I am trying to query an oracle db.
>
> raw sql:
> SELECT fld1, fld2 FROM tbl1 WHERE fld1 < 20;
>
> I can successfully run the query in SQLPlus and using cx_Oracle
> directly in web2py.
>
> > import cx_Oracle
> > orcl = cx_Oracle.connect('user/passw...@tns')
> > curs = orcl.cursor()
> > curs.execute(sql)
> > print curs.fetchall()
>
> When I try to run the query with DAL I get an KeyError:
>
> > db=('DAL://user/p...@tns')
> > print db(db.tbl1.fld1<20).select(fld1,fld2)
>
> Traceback (most recent call last):
>   File "<console>", line 1, in <module>
>   File "C:\web2py\gluon\sql.py", line 1295, in __getattr__
>      return dict.__getitem(self,key)
> KeyError: 'tbl1'
>
> Probably a really silly question but do I need to db.define_table for
> an existing table? Is the table name case sensitive?

Yes, you have to define_table before web2py can use it.
When accessing an existing table, i.e., a table not created by web2py
in the current application, always set migrate=False.
I don't know if table names are case sensitive in Oracle.

Denes

-- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web...@googlegroups.com.
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en.

Reply via email to