[DB-SIG] Can't connect
Chris Cogdon
chris at cogdon.org
Wed Feb 11 22:46:52 EST 2004
On Feb 11, 2004, at 19:41, Russell Shaw wrote:
> Hi,
> I just learnt python. In my python file,
> i have:
>
> from pyPgSQL import libpq
> ...
> conn=connect(host="localhost",database="parts",user="russell")
>
>
> I get an error. python db.py:
>
> Traceback (most recent call last):
> File "db.py", line 108, in ?
> conn=connect(host="localhost",database="parts",user="russell")
> NameError: name 'connect' is not defined
Try:
conn = libpq.connect ( ...
The general rule is, when you 'import' something, you have to keep
using that name. So if you:
import X
Then you need to say X.this and X.that
Or, if you:
from X import this, that
then you can use 'this' and 'that' without having to say X.
--
("`-/")_.-'"``-._ Chris Cogdon <chris at cogdon.org>
. . `; -._ )-;-,_`)
(v_,)' _ )`-.\ ``-'
_.- _..-_/ / ((.'
((,.-' ((,/ fL
More information about the DB-SIG
mailing list