def Open(self):
    """Connects to the database and creates the required tables.

    Raises:
      IOError: if the 4n6time tables cannot be created or data not inserted
          in the database.
      OSError: if the 4n6time tables cannot be created or data not inserted
          in the database.
      ValueError: if no database name given.
    """
    if not self._dbname:
      raise ValueError('Missing database name.')

    try:
      if self._append:
        self._connection = MySQLdb.connect(
            self._host, self._user, self._password, self._dbname)
        self._cursor = self._connection.cursor()

      self._connection.set_character_set('utf8')
      self._cursor.execute('SET NAMES utf8')
      self._cursor.execute('SET CHARACTER SET utf8')
      self._cursor.execute('SET character_set_connection=utf8')
      self._cursor.execute('SET GLOBAL innodb_large_prefix=ON')
      self._cursor.execute('SET GLOBAL innodb_file_format=barracuda')
      self._cursor.execute('SET GLOBAL innodb_file_per_table=ON')
      self._cursor.execute(
          'CREATE DATABASE IF NOT EXISTS {0:s}'.format(self._dbname))
      self._cursor.execute('USE {0:s}'.format(self._dbname))
      # Create tables.
      self._cursor.execute(self._CREATE_TABLE_QUERY)
      if self._set_status:
        self._set_status('Created table: log2timeline')

      for field in self._META_FIELDS:
        self._cursor.execute(
            'CREATE TABLE IF NOT EXISTS l2t_{0}s ({0}s TEXT, frequency INT) '
            'ENGINE=InnoDB ROW_FORMAT=COMPRESSED'.format(field))
        if self._set_status:
          self._set_status('Created table: l2t_{0:s}'.format(field))

      self._cursor.execute(
          'CREATE TABLE IF NOT EXISTS l2t_tags (tag TEXT) '
          'ENGINE=InnoDB ROW_FORMAT=COMPRESSED')
      if self._set_status:
        self._set_status('Created table: l2t_tags')

      self._cursor.execute(
          'CREATE TABLE IF NOT EXISTS l2t_saved_query ('
          'name TEXT, query TEXT) '
          'ENGINE=InnoDB ROW_FORMAT=COMPRESSED')
      if self._set_status:
        self._set_status('Created table: l2t_saved_query')

      self._cursor.execute(
          'CREATE TABLE IF NOT EXISTS l2t_disk ('
          'disk_type INT, mount_path TEXT, '
          'dd_path TEXT, dd_offset TEXT, '
          'storage_file TEXT, export_path TEXT) '
          'ENGINE=InnoDB ROW_FORMAT=COMPRESSED')
      self._cursor.execute(
          'INSERT INTO l2t_disk ('
          'disk_type, mount_path, dd_path, '
          'dd_offset, storage_file, '
          'export_path) VALUES '
          '(0, "", "", "", "", "")')
      if self._set_status:
        self._set_status('Created table: l2t_disk')
    except MySQLdb.Error as exception:
      raise IOError('Unable to insert into database with error: {0!s}'.format(
          exception))

    self._count = 0
Connects to the database and creates the required tables.

    Raises:
      IOError: if the 4n6time tables cannot be created or data not inserted
          in the database.
      OSError: if the 4n6time tables cannot be created or data not inserted
          in the database.
      ValueError: if no database name given.