1
    import pgdb
    myConnection = pgdb.connect( host=hostname, user=username, password=password, database=database )
    doQuery( myConnection )
    myConnection.close()

I get the following error when i run the script.

>>> AttributeError: 'module' object has no attribute 'connect'. Please help me out
Aleksander Ikleiw
  • 2,549
  • 1
  • 8
  • 26
sham sar
  • 45
  • 1
  • 7

2 Answers2

1

The classname is Connection in the repo https://github.com/KehaoWu/pgdb/blob/master/pgdb/pgdb.py#L15

PYPY project pypi.org/project/pgdb

Vikas Mulaje
  • 727
  • 6
  • 11
0

It is like that you have installed the "wrong" pgdb module. Try this:

python3.9 -m pip uninstall pgdb
python3.9 -m pip   install PyGreSQL

"You may either choose to use the “classic” PyGreSQL interface provided by the pg module or else the newer DB-API 2.0 compliant interface provided by the pgdb module." per http://www.pygresql.org/contents/pgdb/introduction.html . It is confusing to have two different modules with the same name.

puravidaso
  • 1,013
  • 1
  • 5
  • 22