class_docstr: Class used to write data to an assets db.
  
  Parameters
  ----------
  engine : Engine or str
      An SQLAlchemy engine or path to a SQL database.
class_docstr_tok: ["Class","used","to","write","data","to","an","assets","db",".","Parameters","--","--","--","--","--","engine",":","Engine","or","str","An","SQLAlchemy","engine","or","path","to","a","SQL","database","."]
docstr: Connect to database and create tables.
  
  Parameters
  ----------
  txn : sa.engine.Connection, optional
      The transaction to execute in. If this is not provided, a new
      transaction will be started with the engine provided.
  
  Returns
  -------
  metadata : sa.MetaData
      The metadata that describes the new assets db.
docstr_tok: ["Connect","to","database","and","create","tables",".","Parameters","--","--","--","--","--","txn",":","sa.engine.Connection",",","optional","The","transaction","to","execute","in",".","If","this","is","not","provided",",","a","new","transaction","will","be","started","with","the","engine","provided",".","Returns","--","--","--","-","metadata",":","sa.MetaData","The","metadata","that","describes","the","new","assets","db","."]
code: def init_db(self, txn=None):
      """Connect to database and create tables.
  
      Parameters
      ----------
      txn : sa.engine.Connection, optional
          The transaction to execute in. If this is not provided, a new
          transaction will be started with the engine provided.
  
      Returns
      -------
      metadata : sa.MetaData
          The metadata that describes the new assets db.
      """
      with ExitStack() as stack:
          if txn is None:
              txn = stack.enter_context(self.engine.begin())
  
          tables_already_exist = self._all_tables_present(txn)
  
          # Create the SQL tables if they do not already exist.
          metadata.create_all(txn, checkfirst=True)
  
          if tables_already_exist:
              check_version_info(txn, version_info, ASSET_DB_VERSION)
          else:
              write_version_info(txn, version_info, ASSET_DB_VERSION)
  
imports: from collections import namedtuple
  import re
  import numpy
  import pandas
  import sqlalchemy
  from toolz import first
  from zipline.errors import AssetDBVersionError
  from zipline.assets.asset_db_schema import ASSET_DB_VERSION, asset_db_table_names, asset_router, equities, equity_symbol_mappings, equity_supplementary_mappings, futures_contracts, exchanges, futures_root_symbols, metadata, version_info
  from zipline.utils.compat import ExitStack
  from zipline.utils.preprocess import preprocess
  from zipline.utils.range import from_tuple, intersecting_ranges
  from zipline.utils.sqlite_utils import coerce_string_to_eng
label_desc: Use image node_id 8 for calling the AssetDBWriter obj's underlying member method code with example usage: obj.init_db(txn) without return types