From eb47196f66e91ece225f5be7e71c86e60dcf1de7 Mon Sep 17 00:00:00 2001 From: Seok Won <ikr@kakao.com> Date: Tue, 15 Dec 2020 22:18:02 +0900 Subject: [PATCH] Remove unused codes --- python/src/AjouSlackProducerMySQL.py | 19 ------------------- python/tests/test_mysql.py | 11 +++++++++++ 2 files changed, 11 insertions(+), 19 deletions(-) diff --git a/python/src/AjouSlackProducerMySQL.py b/python/src/AjouSlackProducerMySQL.py index 8e413fa..f65b66e 100644 --- a/python/src/AjouSlackProducerMySQL.py +++ b/python/src/AjouSlackProducerMySQL.py @@ -2,8 +2,6 @@ import datetime import json import os import time -from contextlib import contextmanager -from pathlib import Path import mysql.connector import requests @@ -22,23 +20,6 @@ def acked(err, msg): print("Message produced: {0}...".format(msg.value())) -@contextmanager -def OPEN_DB(): - # connect to my local MySQL instance using connection string - db = mysql.connector.connect( - host="localhost", - user=os.environ["MYSQL_USER"], - password=os.environ["MYSQL_PASSWORD"], - database="ajou_notices", - charset="utf8", - ) - cursor = db.cursor(buffered=True) - yield cursor - db.commit() # always commits - cursor.close() - db.close() - - def checkOldness(db): pass diff --git a/python/tests/test_mysql.py b/python/tests/test_mysql.py index 633858d..0e531c2 100644 --- a/python/tests/test_mysql.py +++ b/python/tests/test_mysql.py @@ -110,6 +110,17 @@ def test_updateDB(): assert row is not None +def test_printDB(): + with OPEN_DB() as cursor: + cursor.execute( + "SELECT * FROM notices ORDER BY id" + ) # query = SELECT * FROM testdb.notices LIMIT 3; + + for row in cursor: + print(row) + assert row is not None + + def test_lastparsed(): """Test LAST_PARSED update""" from datetime import datetime -- GitLab