Skip to content

Commit 7bb050e

Browse files
committed
added poetry support
1 parent 1a2c0a0 commit 7bb050e

File tree

11 files changed

+757
-14
lines changed

11 files changed

+757
-14
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ coverage.xml
5252
*.pot
5353

5454
# Django stuff:
55-
*.log
5655
local_settings.py
5756
db.sqlite3
5857

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ SQLAlchemy = "*"
1010
PyBigQuery = "*"
1111
PyMySQL = "*"
1212
Psycopg2-Binary = "*"
13+
Loguru = "*"
1314

1415
[requires]
1516
python_version = "3.7"

Pipfile.lock

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

README.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,38 @@
1313

1414
![BigQuery SQLAlchemy Tutorial](https://res-5.cloudinary.com/hackers/image/upload/q_auto:best/v1/2019/11/bigquery-sql.jpg)
1515

16-
Lightweight ETL script to migrate data from BigQuery to SQL databases, or vice versa.
16+
Lightweight ETL script to migrate data from BigQuery to SQL databases, or vice versa. Tutorial found here: https://hackersandslackers.com/bigquery-and-sql-databases/
1717

1818
## Getting Started
1919

20-
Installation is recommended with [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/):
20+
Installation via [Pipenv](https://pipenv-fork.readthedocs.io/en/latest/):
2121

2222
```shell
2323
$ git clone https://github.com/hackersandslackers/bigquery-python-tutorial.git
24-
$ cd bigquery-python-tutorial
24+
$ cd bigquery-sqlalchemy-tutorial
2525
$ pipenv shell
2626
$ pipenv update
2727
$ python3 main.py
2828
```
29+
30+
Installation via [Poetry](https://python-poetry.org/):
31+
32+
```shell
33+
$ git clone https://github.com/hackersandslackers/bigquery-python-tutorial.git
34+
$ cd bigquery-sqlalchemy-tutorial
35+
$ poetry install
36+
$ poetry run
37+
```
38+
39+
Alternatively, try installing via `setup.py`:
40+
41+
```shell
42+
$ git clone https://github.com/hackersandslackers/bigquery-python-tutorial.git
43+
$ cd bigquery-sqlalchemy-tutorial
44+
$ python3 setup.py install
45+
$ python3 main.py
46+
```
47+
48+
-----
49+
50+
**Hackers and Slackers** tutorials are free of charge. If you found this tutorial helpful, a [small donation](https://www.buymeacoffee.com/hackersslackers) would be greatly appreciated to keep us in business. All proceeds go towards coffee, and all coffee goes towards more content.

biquery_sql_etl/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
from biquery_sql_etl.sources.bigquery import bqc
22
from biquery_sql_etl.sources.sqldatabase import dbc
33
from biquery_sql_etl.queries import sql_queries
4+
from loguru import logger
5+
6+
7+
logger.add('logs/queries.log', format="{time} {message}", level="INFO")
48

59

610
def main():
711
"""Move data between sources."""
812
for k, v in sql_queries.items():
913
fetched_rows = bqc.fetch_rows(v)
1014
inserted_rows = dbc.insert_rows(fetched_rows, k, replace=True)
11-
print(inserted_rows)
15+
logger.info(inserted_rows)
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
from .bigquery import bqc
2-
from .sqldatabase import dbc
1+
all = ['bigquery', 'sqldatabase']

biquery_sql_etl/sources/client.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
"""Base Data Client."""
2-
import logging
32
from sqlalchemy import Table
43

54

6-
logging.basicConfig(filename='logs/queries.log',
7-
format='%(asctime)s %(message)s')
8-
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO)
9-
10-
115
class BaseClient:
126

137
def __init__(self, engine=None, metadata=None, table=None):

logs/queries.log

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# QUERY HISTORY

0 commit comments

Comments
 (0)