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
  • trunk/module/tests/test_dbapi20.py

    r665 r667  
    5050            con = self._connect()
    5151            con.close()
    52         except pgdb.Error:
     52        except pgdb.Error:  # try to create a missing database
     53            warning.
    5354            import pg
    54             pg.DB().query('create database ' + dbname)
     55            try:  # first try to log in as superuser
     56                db = pg.DB('postgres', dbhost or None, dbport or -1,
     57                    user='postgres')
     58            except Exception:  # then try to log in as current user
     59                db = pg.DB('postgres', dbhost or None, dbport or -1)
     60            db.query('create database ' + dbname)
    5561
    5662    def tearDown(self):
Note: See TracChangeset for help on using the changeset viewer.