def __init__(self, filename=None, db=None, get_trace=None, upgrade=True, load_functions=False, kwargs=None):
        """
        :param filename:  FILE TO USE FOR DATABASE
        :param db: AN EXISTING sqlite3 DB YOU WOULD LIKE TO USE (INSTEAD OF USING filename)
        :param get_trace: GET THE STACK TRACE AND THREAD FOR EVERY DB COMMAND (GOOD FOR DEBUGGING)
        :param upgrade: REPLACE PYTHON sqlite3 DLL WITH MORE RECENT ONE, WITH MORE FUNCTIONS (NOT WORKING)
        :param load_functions: LOAD EXTENDED MATH FUNCTIONS (MAY REQUIRE upgrade)
        :param kwargs:
        """
        global _upgraded
        global _sqlite3

        self.settings = kwargs
        if not _upgraded:
            if upgrade:
                _upgrade()
            _upgraded = True
            import sqlite3 as _sqlite3
            _ = _sqlite3

        self.filename = File(filename).abspath if filename else None
        if known_databases.get(self.filename):
            Log.error("Not allowed to create more than one Sqlite instance for {{file}}", file=self.filename)

        # SETUP DATABASE
        DEBUG and Log.note("Sqlite version {{version}}", version=_sqlite3.sqlite_version)
        try:
            if db == None:
                self.db = _sqlite3.connect(
                    database=coalesce(self.filename, ":memory:"),
                    check_same_thread=False,
                    isolation_level=None
                )
            else:
                self.db = db
        except Exception as e:
            Log.error("could not open file {{filename}}", filename=self.filename, cause=e)
        load_functions and self._load_functions()

        self.locker = Lock()
        self.available_transactions = []  # LIST OF ALL THE TRANSACTIONS BEING MANAGED
        self.queue = Queue("sql commands")   # HOLD (command, result, signal, stacktrace) TUPLES

        self.get_trace = coalesce(get_trace, TRACE)
        self.upgrade = upgrade
        self.closed = False

        # WORKER VARIABLES
        self.transaction_stack = []  # THE TRANSACTION OBJECT WE HAVE PARTIALLY RUN
        self.last_command_item = None  # USE THIS TO HELP BLAME current_transaction FOR HANGING ON TOO LONG
        self.too_long = None
        self.delayed_queries = []
        self.delayed_transactions = []
        self.worker = Thread.run("sqlite db thread", self._worker)

        DEBUG and Log.note("Sqlite version {{version}}", version=self.query("select sqlite_version()").data[0][0])
def __init__ ( self , filename = None , db = None , get_trace = None , upgrade = True , load_functions = False , kwargs = None ) : global _upgraded global _sqlite3 self . settings = kwargs if not _upgraded : if upgrade : _upgrade ( ) _upgraded = True import sqlite3 as _sqlite3 _ = _sqlite3 self . filename = File ( filename ) . abspath if filename else None if known_databases . get ( self . filename ) : Log . error ( "Not allowed to create more than one Sqlite instance for {{file}}" , file = self . filename ) DEBUG and Log . note ( "Sqlite version {{version}}" , version = _sqlite3 . sqlite_version ) try : if db == None : self . db = _sqlite3 . connect ( database = coalesce ( self . filename , ":memory:" ) , check_same_thread = False , isolation_level = None ) else : self . db = db except Exception as e : Log . error ( "could not open file {{filename}}" , filename = self . filename , cause = e ) load_functions and self . _load_functions ( ) self . locker = Lock ( ) self . available_transactions = [ ] self . queue = Queue ( "sql commands" ) self . get_trace = coalesce ( get_trace , TRACE ) self . upgrade = upgrade self . closed = False self . transaction_stack = [ ] self . last_command_item = None self . too_long = None self . delayed_queries = [ ] self . delayed_transactions = [ ] self . worker = Thread . run ( "sqlite db thread" , self . _worker ) DEBUG and Log . note ( "Sqlite version {{version}}" , version = self . query ( "select sqlite_version()" ) . data [ 0 ] [ 0 ] )
:param filename:  FILE TO USE FOR DATABASE
        :param db: AN EXISTING sqlite3 DB YOU WOULD LIKE TO USE (INSTEAD OF USING filename)
        :param get_trace: GET THE STACK TRACE AND THREAD FOR EVERY DB COMMAND (GOOD FOR DEBUGGING)
        :param upgrade: REPLACE PYTHON sqlite3 DLL WITH MORE RECENT ONE, WITH MORE FUNCTIONS (NOT WORKING)
        :param load_functions: LOAD EXTENDED MATH FUNCTIONS (MAY REQUIRE upgrade)
        :param kwargs: