def test_destroy(self): self.assertFalse(hstore.exists(connection_uri, 'test')) c = self.open_connection(connection_uri) d = hstore.open(c, 'test') self.assertTrue(hstore.exists(connection_uri, 'test')) d.destroy() self.assertFalse(hstore.exists(connection_uri, 'test'))
def test_destroy_after_close(self): self.assertFalse(hstore.exists(connection_uri, 'test')) c = self.open_connection(connection_uri) d = hstore.open(c, 'test') self.assertTrue(hstore.exists(connection_uri, 'test')) d.close() with self.assertRaises(ValueError): d.destroy() # must be open to destroy
def dbopen(name): if create: return hstore.open(self.__connection, name) if hstore.exists(self.__connection, name): return hstore.open(self.__connection, name) raise ValueError('hstore {} does not exist'.format(name))
def open_hstore(self, connection_or_uri, name, table='hstores'): d = hstore.open(connection_or_uri, name, table=table) self.hstores.append(d) return d