def connect(self, database_path, mode="<STR_LIT:a>"):
self.close()<EOL>logger.debug("<STR_LIT>".format(database_path, mode))<EOL>if mode == "<STR_LIT:r>":<EOL><INDENT>self.__verify_db_file_existence(database_path)<EOL><DEDENT>elif mode in ["<STR_LIT:w>", "<STR_LIT:a>"]:<EOL><INDENT>self.__validate_db_path(database_path)<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" + mode)<EOL><DEDENT>if database_path == MEMORY_DB_NAME:<EOL><INDENT>self.__database_path = database_path<EOL><DEDENT>else:<EOL><INDENT>self.__database_path = os.path.realpath(database_path)<EOL><DEDENT>try:<EOL><INDENT>self.__connection = sqlite3.connect(database_path)<EOL><DEDENT>except sqlite3.OperationalError as e:<EOL><INDENT>raise OperationalError(e)<EOL><DEDENT>self.__mode = mode<EOL>try:<EOL><INDENT>self.fetch_table_names()<EOL><DEDENT>except sqlite3.DatabaseError as e:<EOL><INDENT>raise DatabaseError(e)<EOL><DEDENT>if mode != "<STR_LIT:w>":<EOL><INDENT>return<EOL><DEDENT>for table in self.fetch_table_names():<EOL><INDENT>self.drop_table(table)<EOL><DEDENT>
Connect to a SQLite database.

:param str database_path:
    Path to the SQLite database file to be connected.
:param str mode:
    ``"r"``: Open for read only.
    ``"w"``: Open for read/write.
    Delete existing tables when connecting.
    ``"a"``: Open for read/write. Append to the existing tables.
:raises ValueError:
    If ``database_path`` is invalid or |attr_mode| is invalid.
:raises simplesqlite.DatabaseError:
    If the file is encrypted or is not a database.
:raises simplesqlite.OperationalError:
    If unable to open the database file.