Skip to content

Commit de5d80f

Browse files
committed
naming
1 parent 51f3533 commit de5d80f

7 files changed

Lines changed: 29 additions & 29 deletions

File tree

Pipfile.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

application/__init__.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Application entry point."""
2-
from application import main
2+
from src import main
33

44
if __name__ == '__main__':
55
main()

requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
cachetools==3.1.1
22
certifi==2019.9.11
33
chardet==3.0.4
4-
future==0.18.1
4+
future==0.18.2
55
google-api-core==1.14.3
6-
google-auth==1.6.3
6+
google-auth==1.7.0
77
google-cloud-bigquery==1.21.0
88
google-cloud-core==1.0.3
99
google-resumable-media==0.4.1
@@ -17,6 +17,6 @@ PyMySQL==0.9.3
1717
pytz==2019.3
1818
requests==2.22.0
1919
rsa==4.0
20-
six==1.12.0
20+
six==1.13.0
2121
SQLAlchemy==1.3.10
2222
urllib3==1.25.6

src/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import logging
2+
from .bigquery import BigQueryClient
3+
from .database import MySQLClient
4+
from config import Config
5+
6+
logging.basicConfig(format='%(asctime)s \n%(message)s',
7+
level=logging.INFO)
8+
9+
10+
def main():
11+
bigquery = BigQueryClient(Config)
12+
mysql = MySQLClient(Config)
13+
bq_rows = bigquery.fetch_bigquery_rows(Config.bigquery_query)
14+
updated = mysql.insert_rows(bq_rows)
15+
logging.info(f'Top posts this week: {updated}')
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ def __init__(self, Config):
99
self.metadata = MetaData()
1010
self.uri = Config.bigquery_uri
1111
self.credentials = Config.gcp_credentials
12-
self.query = Config.bigquery_query
1312
self.engine = create_engine(self.uri,
1413
credentials_path=self.credentials)
1514

16-
def fetch_bigquery_rows(self):
15+
def fetch_bigquery_rows(self, query):
1716
"""Fetch rows from BigQuery via query."""
18-
results = self.engine.execute(self.query).fetchall()
17+
results = self.engine.execute(query).fetchall()
1918
return results

0 commit comments

Comments
 (0)