import logging from multiprocessing import Process import time import boto3 import pymysql.cursors import config logger = logging.getLogger() logger.setLevel(config.LOGGER_LEVEL) logging.basicConfig( filename=f"select-temp-dig-sales-proccessed.log", filemode="a", format="%(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s", datefmt="%H:%M:%S", level=logging.INFO, ) def get_mysql_connection(): connection = pymysql.connect( host=config.MYSQL_HOST, user=config.MYSQL_USER, password=config.MYSQL_PASSWORD, database=config.MYSQL_DATABASE, charset="utf8mb4", cursorclass=pymysql.cursors.DictCursor, ) return connection def main(): connection = get_mysql_connection() logger.info("Got a MySQL connection") with connection.cursor() as cursor: now = time.time() sql = f"INSERT INTO accountingflat.TEMP_dig_sales_processed SELECT statement_detail_id, 'N' FROM accountingflat.TEMP_dig_sales_statements;" # sql = f"SELECT SLEEP(30);" cursor.execute(sql) post_query = time.time() logger.info(f"Query time for is select total dsd is {post_query - now}\n") result = cursor.fetchone() logger.info(f"Result is {result}") connection.commit() if __name__ == "__main__": main()