def __init__( self, database_id, instance, ddl_statements=(), pool=None, logger=None, encryption_config=None, ): self.database_id = database_id self._instance = instance self._ddl_statements = _check_ddl_statements(ddl_statements) self._local = threading.local() self._state = None self._create_time = None self._restore_info = None self._version_retention_period = None self._earliest_version_time = None self._encryption_info = None self.log_commit_stats = False self._logger = logger self._encryption_config = encryption_config if pool is None: pool = BurstyPool() self._pool = pool pool.bind(self)
def __init__(self, database_id, instance, ddl_statements=(), pool=None): self.database_id = database_id self._instance = instance self._ddl_statements = _check_ddl_statements(ddl_statements) self._local = threading.local() if pool is None: pool = BurstyPool() self._pool = pool pool.bind(self)
def ensure_database(client): instance = client.instance(INSTANCE_NAME) if not instance.exists(): configs = list(client.list_instance_configs()) config_name = configs[0].name print_func("Creating instance: {}".format(INSTANCE_NAME)) instance = client.instance(INSTANCE_NAME, config_name) operation = instance.create() operation.result(30) else: print_func("Instance exists: {}".format(INSTANCE_NAME)) instance.reload() pool = BurstyPool() database = instance.database( DATABASE_NAME, ddl_statements=DDL_STATEMENTS, pool=pool ) if not database.exists(): print_func("Creating database: {}".format(DATABASE_NAME)) operation = database.create() operation.result(30) else: print_func("Database exists: {}".format(DATABASE_NAME)) database.reload() return database
def _item_to_database(self, iterator, database_pb): """Convert a database protobuf to the native object. :type iterator: :class:`~google.api_core.page_iterator.Iterator` :param iterator: The iterator that is currently in use. :type database_pb: :class:`~google.spanner.admin.database.v1.Database` :param database_pb: A database returned from the API. :rtype: :class:`~google.cloud.spanner_v1.database.Database` :returns: The next database in the page. """ return Database.from_pb(database_pb, self, pool=BurstyPool())