web.select() in terminal

3 views
Skip to first unread message

dou...@gmail.com

unread,
Aug 31, 2007, 12:00:19 PM8/31/07
to web.py
Hi, I wanted to test out some code in the terminal, as that's
generally quicker than constantly reloading a page and I couldn't get
the web.select to work. Here's what I did:

>>> import web
>>> web.config.db_parameters = dict(dbn='mysql', user='my_db_user', pw='my_db_pw', db='my_db_name', charset="utf8")
>>> tags = web.select('tags_posts LEFT JOIN tags ON tags.id=tags_posts.tag_id', what='tags.id, tags.name', where='tags_posts.post_id=\'1\' ORDER BY tags.name ASC')

I then got the following errors:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/web/db.py", line 584, in select
return query(qout, processed=True)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/web/db.py", line 436, in query
db_cursor = web.ctx.db_cursor()
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/web/utils.py", line 706, in __getattr__
return getattr(self.__d[threading.currentThread()], attr)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/web/utils.py", line 54, in __getattr__
raise AttributeError, k
AttributeError: 'db_cursor'

Any thoughts would be appreciated, thanks!

-Dougal

dou...@gmail.com

unread,
Aug 31, 2007, 12:02:09 PM8/31/07
to web.py
P.S. This query does work fine in the context of my web app when
running it in Lighttpd...

Hermann Kaser

unread,
Aug 31, 2007, 12:02:46 PM8/31/07
to we...@googlegroups.com

Try doing

web.load()

before the first query.

--
Hermann Käser
http://theragingche.com/
http://semicir.cl/user/hermzz

dou...@gmail.com

unread,
Aug 31, 2007, 2:02:04 PM8/31/07
to web.py
Works, thanks!

Reply all
Reply to author
Forward
0 new messages