Skip to content

Commit

Permalink
Revert "Update"
Browse files Browse the repository at this point in the history
This reverts commit 9888b5d.
  • Loading branch information
rzats committed Jan 17, 2024
1 parent 9888b5d commit 6b821c7
Show file tree
Hide file tree
Showing 30 changed files with 69 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import unittest

# third party
import MySQLdb
import mysql.connector
import requests

# first party
Expand All @@ -32,11 +32,11 @@ def setUp(self):
"""Perform per-test setup."""

# connect to the `epidata` database
cnx = MySQLdb.connect(
cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
db='covid')
database='covid')
cur = cnx.cursor()

# clear all tables
Expand All @@ -58,7 +58,7 @@ def setUp(self):
secrets.db.host = 'delphi_database_epidata'
secrets.db.epi = ('user', 'pass')

epidata_cnx = MySQLdb.connect(
epidata_cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
Expand Down
6 changes: 3 additions & 3 deletions integrations/acquisition/covidcast/test_csv_uploading.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import argparse

# third party
import MySQLdb
import mysql.connector
import pandas as pd
import numpy as np

Expand All @@ -28,7 +28,7 @@ def setUp(self):
"""Perform per-test setup."""

# connect to the `epidata` database and clear the `covidcast` table
cnx = MySQLdb.connect(
cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
Expand All @@ -55,7 +55,7 @@ def setUp(self):
secrets.db.host = 'delphi_database_epidata'
secrets.db.epi = ('user', 'pass')

epidata_cnx = MySQLdb.connect(
epidata_cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
Expand Down
4 changes: 2 additions & 2 deletions integrations/server/test_covidcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import unittest

# third party
import MySQLdb
import mysql.connector

# first party
from delphi_utils import Nans
Expand Down Expand Up @@ -369,7 +369,7 @@ def test_unique_key_constraint(self):
row = self._insert_placeholder_set_one()

# fail to insert different placeholder data under the same key
with self.assertRaises(MySQLdb._exceptions.IntegrityError):
with self.assertRaises(mysql.connector.errors.IntegrityError):
self._insert_placeholder_set_one()

# succeed to insert different placeholder data under a different time_type
Expand Down
4 changes: 2 additions & 2 deletions integrations/server/test_covidcast_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest

# third party
import MySQLdb
import mysql.connector
import requests

#first party
Expand Down Expand Up @@ -53,7 +53,7 @@ def localSetUp(self):
"""Perform per-test setup."""

# connect to the `epidata` database and clear the `covidcast` table
cnx = MySQLdb.connect(
cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
Expand Down
4 changes: 2 additions & 2 deletions integrations/server/test_fluview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest

# third party
import MySQLdb
import mysql.connector

# first party
from delphi.epidata.client.delphi_epidata import Epidata
Expand All @@ -25,7 +25,7 @@ def setUp(self):
"""Perform per-test setup."""

# connect to the `epidata` database and clear the `fluview` table
cnx = MySQLdb.connect(
cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
Expand Down
4 changes: 2 additions & 2 deletions integrations/server/test_fluview_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest

# third party
import MySQLdb
import mysql.connector

# first party
from delphi.epidata.client.delphi_epidata import Epidata
Expand All @@ -25,7 +25,7 @@ def setUp(self):
"""Perform per-test setup."""

# connect to the `epidata` database and clear the `fluview` table
cnx = MySQLdb.connect(
cnx = mysql.connector.connect(
user='user',
password='pass',
host='delphi_database_epidata',
Expand Down
2 changes: 1 addition & 1 deletion requirements.api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ redis==3.5.3
requests==2.31.0
scipy==1.10.0
sentry-sdk[flask]
SQLAlchemy==1.4.51
SQLAlchemy==1.4.40
structlog==22.1.0
tenacity==7.0.0
typing-extensions
Expand Down
2 changes: 2 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ invoke>=1.4.1
lxml==4.9.1
matplotlib==3.6.2
mypy>=0.790
mysql-connector-python==8.2.0
numpy==1.22.4
pycountry==22.3.5
pymysql==1.1.0
pytest==7.2.0
pytest-check==1.3.0
sas7bdat==2.2.3
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/cdcp/cdc_dropbox_receiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

# third party
import dropbox
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand All @@ -47,7 +47,7 @@ def trigger_further_processing():

# connect
u, p = secrets.db.auto
cnx = MySQLdb.connect(user=u, password=p, database="automation")
cnx = mysql.connector.connect(user=u, password=p, database="automation")
cur = cnx.cursor()

# add step "Process CDCP Data" to queue
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/cdcp/cdc_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
import sys

# third party
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand Down Expand Up @@ -154,7 +154,7 @@ def extract(first_week=None, last_week=None, test_mode=False):

# connect
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata")
cnx = mysql.connector.connect(user=u, password=p, database="epidata")
cur = cnx.cursor()

# weeks to update
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/cdcp/cdc_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
from zipfile import ZipFile

# third party
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand Down Expand Up @@ -165,7 +165,7 @@
def upload(test_mode):
# connect
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata")
cnx = mysql.connector.connect(user=u, password=p, database="epidata")
cur = cnx.cursor()

# insert (or update) table `cdc`
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/covid_hosp/common/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import math

# third party
import MySQLdb
import mysql.connector
import pandas as pd

# first party
Expand Down Expand Up @@ -60,7 +60,7 @@ def logger(database_class):

@classmethod
@contextmanager
def connect(database_class, mysql_connector_impl=MySQLdb):
def connect(database_class, mysql_connector_impl=mysql.connector):
"""Connect to a database and provide the connection as a context manager.
As long as the context manager exits normally, the connection's transaction
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/covidcast/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# third party
import json
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand Down Expand Up @@ -38,7 +38,7 @@ class Database:
# TODO: also consider that for composite key tuples, like short_comp_key and long_comp_key as used in delete_batch()


def connect(self, connector_impl=MySQLdb):
def connect(self, connector_impl=mysql.connector):
"""Establish a connection to the database."""

u, p = secrets.db.epi
Expand Down
6 changes: 3 additions & 3 deletions src/acquisition/ecdc/ecdc_db_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import tempfile

# third party
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand All @@ -48,7 +48,7 @@

def ensure_tables_exist():
(u, p) = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata")
cnx = mysql.connector.connect(user=u, password=p, database="epidata")
try:
cursor = cnx.cursor()
cursor.execute(
Expand Down Expand Up @@ -98,7 +98,7 @@ def update_from_file(issue, date, dir, test_mode=False):
# Read ECDC data from CSVs and insert into (or update) the database.
# database connection
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata")
cnx = mysql.connector.connect(user=u, password=p, database="epidata")
rows1 = get_rows(cnx, "ecdc_ili")
print(f"rows before: {int(rows1)}")
insert = cnx.cursor()
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/flusurv/flusurv_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
import argparse

# third party
import MySQLdb
import mysql.connector

# first party
from delphi.epidata.acquisition.flusurv import flusurv
Expand Down Expand Up @@ -105,7 +105,7 @@ def update(issue, location_name, test_mode=False):

# connect to the database
u, p = secrets.db.epi
cnx = MySQLdb.connect(host=secrets.db.host, user=u, password=p, database="epidata")
cnx = mysql.connector.connect(host=secrets.db.host, user=u, password=p, database="epidata")
cur = cnx.cursor()
rows1 = get_rows(cur)
print(f"rows before: {int(rows1)}")
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/fluview/fluview_notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import argparse

# third party
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand All @@ -46,7 +46,7 @@

# connect
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata", host=secrets.db.host)
cnx = mysql.connector.connect(user=u, password=p, database="epidata", host=secrets.db.host)
cur = cnx.cursor()

# get the last known issue from the automation table `variables`
Expand Down
8 changes: 4 additions & 4 deletions src/acquisition/fluview/fluview_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
import zipfile

# third party
import MySQLdb
import mysql.connector

# first party
import delphi.operations.secrets as secrets
Expand Down Expand Up @@ -311,7 +311,7 @@ def update_from_file_clinical(issue, date, filename, test_mode=False):

# database connection
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata", host=secrets.db.host)
cnx = mysql.connector.connect(user=u, password=p, database="epidata", host=secrets.db.host)
rows1 = get_rows(cnx, CL_TABLE)
print(f"rows before: {int(rows1)}")
insert = cnx.cursor()
Expand Down Expand Up @@ -376,7 +376,7 @@ def update_from_file_public(issue, date, filename, test_mode=False):

# database connection
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata", host=secrets.db.host)
cnx = mysql.connector.connect(user=u, password=p, database="epidata", host=secrets.db.host)
rows1 = get_rows(cnx, PHL_TABLE)
print(f"rows before: {int(rows1)}")
insert = cnx.cursor()
Expand Down Expand Up @@ -445,7 +445,7 @@ def update_from_file(issue, date, filename, test_mode=False):

# database connection
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata", host=secrets.db.host)
cnx = mysql.connector.connect(user=u, password=p, database="epidata", host=secrets.db.host)
rows1 = get_rows(cnx)
print(f"rows before: {int(rows1)}")
insert = cnx.cursor()
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/fluview/impute_missing_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import argparse

# third party
import MySQLdb
import mysql.connector
import numpy as np

# first party
Expand Down Expand Up @@ -135,7 +135,7 @@ class Sql:
def connect(self):
"""Connect to the database."""
u, p = secrets.db.epi
self.cnx = MySQLdb.connect(user=u, password=p, database="epidata", host=secrets.db.host)
self.cnx = mysql.connector.connect(user=u, password=p, database="epidata", host=secrets.db.host)
self.cur = self.cnx.cursor()

def close(self, commit):
Expand Down
4 changes: 2 additions & 2 deletions src/acquisition/ght/ght_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
import time

# third party
import MySQLdb
import mysql.connector
from apiclient.discovery import build

# first party
Expand Down Expand Up @@ -251,7 +251,7 @@
def update(locations, terms, first=None, last=None, countries=["US"]):
# connect to the database
u, p = secrets.db.epi
cnx = MySQLdb.connect(user=u, password=p, database="epidata")
cnx = mysql.connector.connect(user=u, password=p, database="epidata")
cur = cnx.cursor()

def get_num_rows():
Expand Down
Loading

0 comments on commit 6b821c7

Please sign in to comment.