Changeset 667 for branches/4.x


Ignore:
Timestamp:
Dec 23, 2015, 10:53:02 AM (4 years ago)
Author:
cito
Message:

More sophisticated creation of missing database

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/4.x/module/tests/test_dbapi20.py

    r666 r667  
    4343            con = self._connect()
    4444            con.close()
    45         except pgdb.Error:
     45        except pgdb.Error:  # try to create a missing database
    4646            import pg
    47             pg.DB('postgres',dbhost,dbport).query('create database ' + dbname)
     47            try:  # first try to log in as superuser
     48                db = pg.DB('postgres', dbhost or None, dbport or -1,
     49                    user='postgres')
     50            except Exception:  # then try to log in as current user
     51                db = pg.DB('postgres', dbhost or None, dbport or -1)
     52            db.query('create database ' + dbname)
     53
    4854
    4955    def tearDown(self):
Note: See TracChangeset for help on using the changeset viewer.