def __init__(self, path, timeout = None):
        if timeout is not None:
            self.timeout = timeout
        self.db = None
        try:
            self.db = dbstore.connect(path, driver = "sqlite",
                                      timeout=self.timeout)
            self.schemaVersion = self.db.getVersion().major
        except sqlerrors.DatabaseLocked:
            raise errors.DatabaseLockedError
        self.db.dbh._BEGIN = "BEGIN"

        try:
            # dbstore? what's dbstore
            cu = self.db.cursor()
            cu.execute("BEGIN IMMEDIATE")
        except sqlerrors.ReadOnlyDatabase:
            readOnly = True
        else:
            readOnly = False
            self.db.rollback()
        if readOnly and self.schemaVersion < schema.VERSION:
            raise OldDatabaseSchema(
                "The Conary database on this system is too old.  It will be \n"
                "automatically converted as soon as you run Conary with \n"
                "write permissions for the database (which normally means \n"
                "as root). \n")
        elif self.schemaVersion > schema.VERSION:
            raise schema.NewDatabaseSchema()
        self.db.loadSchema()

        newCursor = self.schemaVersion < schema.VERSION

        schema.checkVersion(self.db)
        if newCursor:
            cu = self.db.cursor()

        if self.schemaVersion == 0:
            schema.createSchema(self.db)
        schema.setupTempDepTables(self.db, cu)
        schema.setupTempTables(self.db, cu)

        self.troveFiles = DBTroveFiles(self.db)
        self.instances = DBInstanceTable(self.db)
        self.versionTable = versiontable.VersionTable(self.db)
        self.flavors = Flavors(self.db)
        self.flavorMap = DBFlavorMap(self.db)
        self.depTables = deptable.DependencyTables(self.db)
        self.troveInfoTable = troveinfo.TroveInfoTable(self.db)

        self.needsCleanup = False
        self.addVersionCache = {}
        self.flavorsNeeded = {}