[DB-SIG] Can't connect
Russell Shaw
rjshaw at iprimus.com.au
Wed Feb 11 23:21:52 EST 2004
Chris Cogdon wrote:
>
> 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.
Thanks, i've read that in the manual. I got it working now. It took me
a while to figure out there's two interfaces (libpq and PgSQL;)
More information about the DB-SIG
mailing list