def get_store_dsn(self): """Get a dsn that can be used to connect to the database Unlike :meth:`.get_store_uri`, this is supported by all PostgreSQL versions when used by `psycopg2.connect`. :returns: a string like "dbname=stoq host=localhost port=5432" """ from storm.databases.postgres import make_dsn return make_dsn(self._create_uri(self.dbname))
def setUp(self): super(PostgresDisconnectionTestWithPGBouncerBase, self).setUp() database_uri = URI(os.environ["STORM_POSTGRES_HOST_URI"]) database_user = database_uri.username or os.environ['USER'] database_dsn = make_dsn(database_uri) # Create a pgbouncer fixture. self.pgbouncer = pgbouncer.fixture.PGBouncerFixture() self.pgbouncer.databases[database_uri.database] = database_dsn self.pgbouncer.users[database_user] = "trusted" self.pgbouncer.admin_users = [database_user] self.useFixture(self.pgbouncer) # Create a Database that uses pgbouncer. pgbouncer_uri = database_uri.copy() pgbouncer_uri.host = self.pgbouncer.host pgbouncer_uri.port = self.pgbouncer.port self.database = create_database(pgbouncer_uri)