import mariadb import time def test(): # create SQL connections pool dbconfig = { "host": '127.0.0.1', "port": 3306, "database": 'mysql', "user": 'root', "password": '123', } conn = mariadb.connect(**dbconfig) counter = 0 try: while True: counter += 1 print(counter) message_record = None cursor = conn.cursor(dictionary=True) cursor.execute('SELECT NOW()') message_record = cursor.fetchall() print(message_record) cursor.close() if counter == 100: import gc gc.collect() counter = 0 time.sleep(.1) except KeyboardInterrupt as ke: print(ke) finally: conn.close() if __name__ == '__main__': test() input('Press ENTER to end.')