def convert_sqlite_to_mysql(
            self):
        """*copy the contents of the sqlite database into the mysql database*

        See class docstring for usage
        """
        from fundamentals.renderer import list_of_dictionaries
        from fundamentals.mysql import directory_script_runner
        self.log.debug('starting the ``convert_sqlite_to_mysql`` method')

        con = lite.connect(self.pathToSqlite)
        con.row_factory = lite.Row
        cur = con.cursor()

        # GET ALL TABLE NAMES
        cur.execute("SELECT name FROM sqlite_master WHERE type='table';")
        tables = cur.fetchall()

        createStatements = []
        inserts = []
        for table in tables:
            table = table['name']
            if table == "sqlite_sequence":
                continue

            # CREATE TABLE collection_books (folder_id, fingerprint, primary key(folder_id, fingerprint));
            # GENEREATE THE MYSQL CREATE STATEMENTS FOR EACH TABLE
            cur.execute(
                "SELECT sql FROM sqlite_master WHERE name = '%(table)s';" % locals())
            createStatement = cur.fetchone()
            createStatement = createStatement[0].replace('"', '`') + ";"
            if "DEFAULT" not in createStatement:
                if "primary key(" in createStatement:
                    tmp = createStatement.split("primary key(")
                    tmp[0] = tmp[0].replace(
                        ",", " varchar(150) DEFAULT NULL,")
                    createStatement = ("primary key(").join(tmp)
                if "primary key," in createStatement:
                    tmp = createStatement.split("primary key,")
                    tmp[1] = tmp[1].replace(
                        ",", " varchar(150) DEFAULT NULL,")
                    tmp[1] = tmp[1].replace(
                        ");", " varchar(150) DEFAULT NULL);")
                    createStatement = ("primary key,").join(tmp)
            createStatement = createStatement.replace(
                "INTEGER PRIMARY KEY", "INTEGER AUTO_INCREMENT PRIMARY KEY")
            createStatement = createStatement.replace(
                "AUTOINCREMENT", "AUTO_INCREMENT")
            createStatement = createStatement.replace(
                "DEFAULT 't'", "DEFAULT '1'")
            createStatement = createStatement.replace(
                "DEFAULT 'f'", "DEFAULT '0'")
            createStatement = createStatement.replace(",'t'", ",'1'")
            createStatement = createStatement.replace(",'f'", ",'0'")
            if "CREATE TABLE `" in createStatement:
                createStatement = createStatement.replace(
                    "CREATE TABLE `", "CREATE TABLE IF NOT EXISTS `" + self.tablePrefix)
            else:
                createStatement = createStatement.replace(
                    "CREATE TABLE ", "CREATE TABLE IF NOT EXISTS " + self.tablePrefix)
            if ", primary key(" in createStatement:
                createStatement = createStatement.replace(", primary key(", """,
`dateCreated` datetime DEFAULT CURRENT_TIMESTAMP,
`dateLastModified` datetime DEFAULT CURRENT_TIMESTAMP,
`updated` tinyint(4) DEFAULT '0',
primary key(""")
            else:
                createStatement = createStatement.replace(");", """,
    `dateCreated` datetime DEFAULT CURRENT_TIMESTAMP,
    `dateLastModified` datetime DEFAULT CURRENT_TIMESTAMP,
    `updated` tinyint(4) DEFAULT '0');
                """)
            createStatement = createStatement.replace(
                " text primary key", " varchar(100) primary key")
            createStatement = createStatement.replace(
                "`EntryText` TEXT NOT NULL,", "`EntryText` TEXT,")
            createStatement = createStatement.replace(
                "`SelectionText` TEXT NOT NULL", "`SelectionText` TEXT")
            createStatement = createStatement.replace(
                "`Filename` INTEGER NOT NULL,", "`Filename` TEXT NOT NULL,")
            createStatement = createStatement.replace(
                "`SessionPartUUID` TEXT NOT NULL UNIQUE,", "`SessionPartUUID` VARCHAR(100) NOT NULL UNIQUE,")
            createStatement = createStatement.replace(
                "`Name` TEXT PRIMARY KEY NOT NULL", "`Name` VARCHAR(100) PRIMARY KEY NOT NULL")
            createStatement = createStatement.replace(
                " VARCHAR ", " VARCHAR(100) ")
            createStatement = createStatement.replace(
                " VARCHAR,", " VARCHAR(100),")

            # GRAB THE DATA TO ADD TO THE MYSQL DATABASE TABLES
            cur.execute(
                "SELECT * from '%(table)s';" % locals())
            rows = cur.fetchall()

            allRows = []
            for row in rows:
                allRows.append(dict(row))

            # RECURSIVELY CREATE MISSING DIRECTORIES
            if not os.path.exists("/tmp/headjack/"):
                os.makedirs("/tmp/headjack/")

            writequery(
                log=self.log,
                sqlQuery=createStatement,
                dbConn=self.dbConn,
            )

            from fundamentals.mysql import insert_list_of_dictionaries_into_database_tables
            # USE dbSettings TO ACTIVATE MULTIPROCESSING
            insert_list_of_dictionaries_into_database_tables(
                dbConn=self.dbConn,
                log=self.log,
                dictList=allRows,
                dbTableName=self.tablePrefix + table,
                uniqueKeyList=[],
                dateModified=True,
                dateCreated=True,
                batchSize=10000,
                replace=True,
                dbSettings=self.settings["database settings"]
            )

            # # DUMP THE DATA INTO A MYSQL DATABASE
            # dataSet = list_of_dictionaries(
            #     log=self.log,
            #     listOfDictionaries=allRows
            # )
            # originalList = dataSet.list
            # now = datetime.now()
            # now = now.strftime("%Y%m%dt%H%M%S%f.sql")
            # mysqlData = dataSet.mysql(
            # tableName=self.tablePrefix + table, filepath="/tmp/headjack/" +
            # now, createStatement=createStatement)

            # directory_script_runner(
            #     log=self.log,
            #     pathToScriptDirectory="/tmp/headjack/",
            #     databaseName=self.settings["database settings"]["db"],
            #     loginPath=self.settings["database settings"]["loginPath"],
            #     successRule="delete",
            #     failureRule="failed"
            # )

        con.close()

        self.log.debug('completed the ``convert_sqlite_to_mysql`` method')
        return None
def convert_sqlite_to_mysql ( self ) : from fundamentals . renderer import list_of_dictionaries from fundamentals . mysql import directory_script_runner self . log . debug ( 'starting the ``convert_sqlite_to_mysql`` method' ) con = lite . connect ( self . pathToSqlite ) con . row_factory = lite . Row cur = con . cursor ( ) cur . execute ( "SELECT name FROM sqlite_master WHERE type='table';" ) tables = cur . fetchall ( ) createStatements = [ ] inserts = [ ] for table in tables : table = table [ 'name' ] if table == "sqlite_sequence" : continue cur . execute ( "SELECT sql FROM sqlite_master WHERE name = '%(table)s';" % locals ( ) ) createStatement = cur . fetchone ( ) createStatement = createStatement [ 0 ] . replace ( '"' , '`' ) + ";" if "DEFAULT" not in createStatement : if "primary key(" in createStatement : tmp = createStatement . split ( "primary key(" ) tmp [ 0 ] = tmp [ 0 ] . replace ( "," , " varchar(150) DEFAULT NULL," ) createStatement = ( "primary key(" ) . join ( tmp ) if "primary key," in createStatement : tmp = createStatement . split ( "primary key," ) tmp [ 1 ] = tmp [ 1 ] . replace ( "," , " varchar(150) DEFAULT NULL," ) tmp [ 1 ] = tmp [ 1 ] . replace ( ");" , " varchar(150) DEFAULT NULL);" ) createStatement = ( "primary key," ) . join ( tmp ) createStatement = createStatement . replace ( "INTEGER PRIMARY KEY" , "INTEGER AUTO_INCREMENT PRIMARY KEY" ) createStatement = createStatement . replace ( "AUTOINCREMENT" , "AUTO_INCREMENT" ) createStatement = createStatement . replace ( "DEFAULT 't'" , "DEFAULT '1'" ) createStatement = createStatement . replace ( "DEFAULT 'f'" , "DEFAULT '0'" ) createStatement = createStatement . replace ( ",'t'" , ",'1'" ) createStatement = createStatement . replace ( ",'f'" , ",'0'" ) if "CREATE TABLE `" in createStatement : createStatement = createStatement . replace ( "CREATE TABLE `" , "CREATE TABLE IF NOT EXISTS `" + self . tablePrefix ) else : createStatement = createStatement . replace ( "CREATE TABLE " , "CREATE TABLE IF NOT EXISTS " + self . tablePrefix ) if ", primary key(" in createStatement : createStatement = createStatement . replace ( ", primary key(" , """,
`dateCreated` datetime DEFAULT CURRENT_TIMESTAMP,
`dateLastModified` datetime DEFAULT CURRENT_TIMESTAMP,
`updated` tinyint(4) DEFAULT '0',
primary key(""" ) else : createStatement = createStatement . replace ( ");" , """,
    `dateCreated` datetime DEFAULT CURRENT_TIMESTAMP,
    `dateLastModified` datetime DEFAULT CURRENT_TIMESTAMP,
    `updated` tinyint(4) DEFAULT '0');
                """ ) createStatement = createStatement . replace ( " text primary key" , " varchar(100) primary key" ) createStatement = createStatement . replace ( "`EntryText` TEXT NOT NULL," , "`EntryText` TEXT," ) createStatement = createStatement . replace ( "`SelectionText` TEXT NOT NULL" , "`SelectionText` TEXT" ) createStatement = createStatement . replace ( "`Filename` INTEGER NOT NULL," , "`Filename` TEXT NOT NULL," ) createStatement = createStatement . replace ( "`SessionPartUUID` TEXT NOT NULL UNIQUE," , "`SessionPartUUID` VARCHAR(100) NOT NULL UNIQUE," ) createStatement = createStatement . replace ( "`Name` TEXT PRIMARY KEY NOT NULL" , "`Name` VARCHAR(100) PRIMARY KEY NOT NULL" ) createStatement = createStatement . replace ( " VARCHAR " , " VARCHAR(100) " ) createStatement = createStatement . replace ( " VARCHAR," , " VARCHAR(100)," ) cur . execute ( "SELECT * from '%(table)s';" % locals ( ) ) rows = cur . fetchall ( ) allRows = [ ] for row in rows : allRows . append ( dict ( row ) ) if not os . path . exists ( "/tmp/headjack/" ) : os . makedirs ( "/tmp/headjack/" ) writequery ( log = self . log , sqlQuery = createStatement , dbConn = self . dbConn , ) from fundamentals . mysql import insert_list_of_dictionaries_into_database_tables insert_list_of_dictionaries_into_database_tables ( dbConn = self . dbConn , log = self . log , dictList = allRows , dbTableName = self . tablePrefix + table , uniqueKeyList = [ ] , dateModified = True , dateCreated = True , batchSize = 10000 , replace = True , dbSettings = self . settings [ "database settings" ] ) con . close ( ) self . log . debug ( 'completed the ``convert_sqlite_to_mysql`` method' ) return None
*copy the contents of the sqlite database into the mysql database*

        See class docstring for usage