pgdb connection string

Johannes Bauer dfnsonfsduifb at gmx.de
Fri Jun 13 16:32:37 CEST 2008


Hello group,

I've run into a small problem with pgdb which is actually not PostgreSQL 
specific - I just do not understand the Python syntax at one point.

I'm trying to initialize a connection to a PG database. So help(pgdb) says:

pgdb.connect(connect_string) -> connection
             connect_string = 'host:database:user:password:opt:tty'
             All parts are optional. You may also pass host through
             password as keyword arguments. To pass a port, pass it in
             the host keyword parameter:
                     pgdb.connect(host='localhost:5432')

Now from what I understand is that it accepts a string in the form:

"%s:%s:%s:%s" % (conf["db"]["hostname"],
                  conf["db"]["database"],
                  conf["db"]["username"],
                  conf["db"]["password"])

Which actually works. But if I want to pass the port, there's one more 
colon and it parses garbage. So what exactly is this host="foobar" 
syntax all about? What exactly is passed to pgdb.connect (because it 
does not seem to be a string) - is it a dictionary or something?

I'm puzzled.

Regards,
Johannes

-- 
"Wer etwas kritisiert muss es noch lange nicht selber besser können. Es
reicht zu wissen, daß andere es besser können und andere es auch
besser machen um einen Vergleich zu bringen."     -     Wolfgang Gerber
       in de.sci.electronics <47fa8447$0$11545$9b622d9e at news.freenet.de>



More information about the Python-list mailing list