On Apr 1, 3:07 pm, Yarko Tymciurak <[email protected]>
wrote:
> Massimo can explain to you how this happens, but this is not a problem
> - it's a feature:

... that is, gluon/dal.py trys to import psycopg2 as it builds up a
list of available drivers;  you just can't see psycopg2, and that's a
good thing.
If you want to deal w/ psycopg2 directly, don't use DAL - do your own
talking to the DB, you can... but one _or_ the other.

- y

>
> From your web2py directory, if you do:
>
> python web2py.py -S welcome -M
>
> to get a web2py application context shell, with your models imported,
> you also get:
>
> In [1]: psycopg2
> ---------------------------------------------------------------------------
> NameError                                 Traceback (most recent call
> last)
> .../web2py-dev/<ipython console> in <module>()
>
> NameError: name 'psycopg2' is not defined
>
> Since, if you were messing with psycopg2, you would be competing with
> DAL, it's a good thing to discourage you from doing so.
>
> If you _really_ want to, your model can also do "import psycopg2" and
> this will "solve your problem" -  but I do not recommend doing this.
>
> If your concern is "can I connect to a postgres db?"  --- then to a
> try/except around   db= DAL(DBURI),   where DBURI is an appropriate
> connection string.
>
> Regards,
> - Yarko
>
> On Apr 1, 2:48 pm, Richie <[email protected]> wrote:
>
> > I can import psycopg2 from a python shell, but I'm getting "NameError:
> > global name 'psycopg2' is not defined" when I try to access my default
> > controller. I'm setup with Apache and MOD WSGI. Anyone got any ideas?
>
> > Thanks!
>
> > Rich

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

Reply via email to