# Buggy code
def __init__(
    self,
    table_name,
    key_columns,
    fixed_length_key=True,
    credentials=None,
    url=None,
    connection_string=None,
    engine=None,
    store_name=None,
    suppress_store_backend_id=False,
    **kwargs,
):
    super().__init__(
        fixed_length_key=fixed_length_key,
        suppress_store_backend_id=suppress_store_backend_id,
        store_name=store_name,
    )
    if not sa:
        raise ge_exceptions.DataContextError(
            "ModuleNotFoundError: No module named 'sqlalchemy'"
        )

    if not self.fixed_length_key:
        raise ge_exceptions.InvalidConfigError(
            "DatabaseStoreBackend requires use of a fixed-length-key"
        )

    self._schema_name = None
    self._credentials = credentials
    self._connection_string = connection_string
    self._url = url

    if engine is not None:
        if credentials is not None:
            logger.warning(
                "Both credentials and engine were provided during initialization of SqlAlchemyExecutionEngine. "
                "Ignoring credentials."
            )
        self.engine = engine
    elif credentials is not None:
        self.engine = self._build_engine(credentials=credentials, **kwargs)
    elif connection_string is not None:
        self.engine = sa.create_engine(connection_string, **kwargs)
    elif url is not None:
        self.drivername = urlparse(url).scheme
        self.engine = sa.create_engine(url, **kwargs)
    else:
        raise ge_exceptions.InvalidConfigError(
            "Credentials, url, connection_string, or an engine are required for a DatabaseStoreBackend."
        )

    meta = MetaData(schema=self._schema_name)
    self.key_columns = key_columns
    # Dynamically construct a SQLAlchemy table with the name and column names we'll use
    cols = []
    for column in key_columns:
        if column == "value":
            raise ge_exceptions.InvalidConfigError(
                "'value' cannot be used as a key_element name"
            )
        cols.append(Column(column, String, primary_key=True))
    cols.append(Column("value", String))
    try:
        table = Table(table_name, meta, autoload=True, autoload_with=self.engine)
        # We do a "light" check: if the columns' names match, we will proceed, otherwise, create the table
        if {str(col.name).lower() for col in table.columns} != (
            set(key_columns) | {"value"}
        ):
            raise ge_exceptions.StoreBackendError(
                f"Unable to use table {table_name}: it exists, but does not have the expected schema."
            )
    except NoSuchTableError:
        table = Table(table_name, meta, *cols)
        try:
            if self._schema_name:
                self.engine.execute(f"CREATE SCHEMA IF NOT EXISTS {self._schema_name};")
            meta.create_all(self.engine)
        except SQLAlchemyError as e:
            raise ge_exceptions.StoreBackendError(
                f"Unable to connect to table {table_name} because of an error. It is possible your table needs to be migrated to a new schema.  SqlAlchemyError: {str(e)}"
            )
    self._table = table
    # Initialize with store_backend_id
    self._store_backend_id = None
    self._store_backend_id = self.store_backend_id


# Traceback (TypeError)
➜  great_expectations store list                                                                                                                                                                              [130 01:40:51P Wed 12/16/20]
Traceback (most recent call last):
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/util.py", line 84, in instantiate_class_from_config
class_instance = class_(**config_with_defaults)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/store/database_store_backend.py", line 76, in __init__
self.engine = self._build_engine(credentials=credentials, **kwargs)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/store/database_store_backend.py", line 164, in _build_engine
engine = sa.create_engine(options, **create_engine_kwargs)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/sqlalchemy/engine/__init__.py", line 500, in create_engine
return strategy.create(*args, **kwargs)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/sqlalchemy/engine/strategies.py", line 164, in create
raise TypeError(
TypeError: Invalid argument(s) 'manually_initialize_store_backend_id' sent to create_engine(), using configuration PGDialect_psycopg2/QueuePool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/util.py", line 84, in instantiate_class_from_config
class_instance = class_(**config_with_defaults)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/store/expectations_store.py", line 133, in __init__
super().__init__(
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/store/store.py", line 42, in __init__
self._store_backend = instantiate_class_from_config(
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/util.py", line 86, in instantiate_class_from_config
raise TypeError(
TypeError: Couldn't instantiate class : DatabaseStoreBackend with config :
store_name		postgres_expectations_store
credentials		{'host': 'localhost', 'port': 5432, 'username': 'great', 'password': 'expectations', 'database': 'ge'}
manually_initialize_store_backend_id		91f04917-fe8e-49b7-bea1-db671ebfeb73
table_name		ge_expectations_store
key_columns		['expectation_suite_name']

Invalid argument(s) 'manually_initialize_store_backend_id' sent to create_engine(), using configuration PGDialect_psycopg2/QueuePool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/ryan/.virtualenvs/ge-13/bin/great_expectations", line 8, in <module>
sys.exit(main())
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/cli/cli.py", line 72, in main
cli()
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/cli/store.py", line 23, in store_list
context = toolkit.load_data_context_with_error_handling(directory)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/cli/toolkit.py", line 404, in load_data_context_with_error_handling
context = DataContext(directory)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/data_context.py", line 3106, in __init__
super().__init__(project_config, context_root_directory, runtime_environment)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/core/usage_statistics/usage_statistics.py", line 261, in usage_statistics_wrapped_method
result = func(*args, **kwargs)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/data_context.py", line 267, in __init__
self._init_stores(self._project_config_with_variables_substituted.stores)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/data_context.py", line 354, in _init_stores
self._build_store_from_config(store_name, store_config)
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/data_context.py", line 324, in _build_store_from_config
new_store = instantiate_class_from_config(
File "/Users/ryan/.virtualenvs/ge-13/lib/python3.8/site-packages/great_expectations/data_context/util.py", line 86, in instantiate_class_from_config
raise TypeError(
TypeError: Couldn't instantiate class : ExpectationsStore with config :
store_name		postgres_expectations_store
store_backend		{'class_name': 'DatabaseStoreBackend', 'credentials': {'drivername': 'postgresql', 'host': 'localhost', 'port': 5432, 'username': 'great', 'password': 'expectations', 'database': 'ge'}, 'manually_initialize_store_backend_id': '91f04917-fe8e-49b7-bea1-db671ebfeb73', 'table_name': 'ge_expectations_store', 'key_columns': ['expectation_suite_name']}
runtime_environment		{'root_directory': '/Users/ryan/local/scratch/great-expectations/ge13/great_expectations'}

Couldn't instantiate class : DatabaseStoreBackend with config :
store_name		postgres_expectations_store
credentials		{'host': 'localhost', 'port': 5432, 'username': 'great', 'password': 'expectations', 'database': 'ge'}
manually_initialize_store_backend_id		91f04917-fe8e-49b7-bea1-db671ebfeb73
table_name		ge_expectations_store
key_columns		['expectation_suite_name']

Invalid argument(s) 'manually_initialize_store_backend_id' sent to create_engine(), using configuration PGDialect_psycopg2/QueuePool/Engine.  Please check that the keyword arguments are appropriate for this combination of components.

# Fixed code
def __init__(
    self,
    table_name,
    key_columns,
    fixed_length_key=True,
    credentials=None,
    url=None,
    connection_string=None,
    engine=None,
    store_name=None,
    suppress_store_backend_id=False,
    manually_initialize_store_backend_id: str = "",
    **kwargs,
):
    super().__init__(
        fixed_length_key=fixed_length_key,
        suppress_store_backend_id=suppress_store_backend_id,
        manually_initialize_store_backend_id=manually_initialize_store_backend_id,
        store_name=store_name,
    )
    if not sa:
        raise ge_exceptions.DataContextError(
            "ModuleNotFoundError: No module named 'sqlalchemy'"
        )

    if not self.fixed_length_key:
        raise ge_exceptions.InvalidConfigError(
            "DatabaseStoreBackend requires use of a fixed-length-key"
        )

    self._schema_name = None
    self._credentials = credentials
    self._connection_string = connection_string
    self._url = url

    if engine is not None:
        if credentials is not None:
            logger.warning(
                "Both credentials and engine were provided during initialization of SqlAlchemyExecutionEngine. "
                "Ignoring credentials."
            )
        self.engine = engine
    elif credentials is not None:
        self.engine = self._build_engine(credentials=credentials, **kwargs)
    elif connection_string is not None:
        self.engine = sa.create_engine(connection_string, **kwargs)
    elif url is not None:
        self.drivername = urlparse(url).scheme
        self.engine = sa.create_engine(url, **kwargs)
    else:
        raise ge_exceptions.InvalidConfigError(
            "Credentials, url, connection_string, or an engine are required for a DatabaseStoreBackend."
        )

    meta = MetaData(schema=self._schema_name)
    self.key_columns = key_columns
    # Dynamically construct a SQLAlchemy table with the name and column names we'll use
    cols = []
    for column in key_columns:
        if column == "value":
            raise ge_exceptions.InvalidConfigError(
                "'value' cannot be used as a key_element name"
            )
        cols.append(Column(column, String, primary_key=True))
    cols.append(Column("value", String))
    try:
        table = Table(table_name, meta, autoload=True, autoload_with=self.engine)
        # We do a "light" check: if the columns' names match, we will proceed, otherwise, create the table
        if {str(col.name).lower() for col in table.columns} != (
            set(key_columns) | {"value"}
        ):
            raise ge_exceptions.StoreBackendError(
                f"Unable to use table {table_name}: it exists, but does not have the expected schema."
            )
    except NoSuchTableError:
        table = Table(table_name, meta, *cols)
        try:
            if self._schema_name:
                self.engine.execute(f"CREATE SCHEMA IF NOT EXISTS {self._schema_name};")
            meta.create_all(self.engine)
        except SQLAlchemyError as e:
            raise ge_exceptions.StoreBackendError(
                f"Unable to connect to table {table_name} because of an error. It is possible your table needs to be migrated to a new schema.  SqlAlchemyError: {str(e)}"
            )
    self._table = table
    # Initialize with store_backend_id
    self._store_backend_id = None
    self._store_backend_id = self.store_backend_id