resources/code/scenario0/api/app.py [106:137]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        try:
            cursor = self.conn.cursor()
            print("Creating table threads")
            cursor.execute("""
                CREATE TABLE IF NOT EXISTS `threads`(
                `id` int NOT NULL,
                `title` varchar(50) NOT NULL,
                `createdBy` int NOT NULL,
                PRIMARY KEY (`id`)
                );
            """)

            cursor.execute("""
                insert into `threads`(`id`,`title`,`createdBy`)
                    values (1,"What's up with the Lich?",1);
            """)

        except mysql.connector.Error as err:
            if err.errno == errorcode.ER_TABLE_EXISTS_ERROR:
                print(f"Table <threads> already exists.")
            else:
                print(err.msg)
        else:
            print(f'Successfully inserted data into table <threads>.')

    def get_connection(self):
        return self.conn


def get_from_db(table):
    if local_db:
        return db.get(table)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



resources/code/scenario1/api-threads/app.py [51:82]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        try:
            cursor = self.conn.cursor()
            print("Creating table threads")
            cursor.execute("""
                CREATE TABLE IF NOT EXISTS `threads`(
                `id` int NOT NULL,
                `title` varchar(50) NOT NULL,
                `createdBy` int NOT NULL,
                PRIMARY KEY (`id`)
                );
            """)

            cursor.execute("""
                insert into `threads`(`id`,`title`,`createdBy`)
                    values (1,"What's up with the Lich?",1);
            """)

        except mysql.connector.Error as err:
            if err.errno == errorcode.ER_TABLE_EXISTS_ERROR:
                print(f"Table <threads> already exists.")
            else:
                print(err.msg)
        else:
            print(f'Successfully inserted data into table <threads>.')

    def get_connection(self):
        return self.conn


def get_from_db(table):
    if local_db:
        return db.get(table)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



