def _stateToDb(self, statefilepath):
        db = dbio.connect(self.dbname)
        cur = db.cursor()
        cur.execute(
            "select schema_name from information_schema.schemata where schema_name='{0}'".format(self.name))
        if not bool(cur.rowcount):
            cur.execute("create schema {0}".format(self.name))
            db.commit()
        cur.execute(
            "select table_name from information_schema.tables where table_schema='{0}' and table_name='state'".format(self.name))
        if not bool(cur.rowcount):
            sql = "create table {0}.state (filename text, fdate date)".format(
                self.name)
            cur.execute(sql)
            db.commit()
        statefile = "{0}/vic.state_{1:04d}{2:02d}{3:02d}".format(
            statefilepath, self.endyear, self.endmonth, self.endday)
        statedate = "{0}-{1}-{2}".format(self.endyear,
                                         self.endmonth, self.endday)
        cur.execute(
            "select * from {0}.state where fdate=date '{1}'".format(self.name, statedate))
        if bool(cur.rowcount):
            sql = "update {0}.state set filename='{1}' where fdate=date '{2}'".format(
                self.name, statefile, statedate)
        else:
            sql = "insert into {0}.state values ('{1}', date '{2}')".format(
                self.name, statefile, statedate)
        cur.execute(sql)
        db.commit()
        cur.close()
        db.close()
Called when the visible trait is changed on an action.
dataset/ETHPy150Open nasa/RHEAS/src/vic/vic.py/VIC._stateToDb--crossover with--dataset/ETHPy150Open enthought/pyface/pyface/ui/wx/action/action_item.py/_Tool._on_action_visible_changed