Skip to content

ENH: query price presentation (uses pyfiglet fonts) #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Changelog
- The dataframe passed to ```.to_gbq(...., if_exists='append')``` needs to contain only a subset of the fields in the BigQuery schema. (:issue:`24`)
- Use the `google-auth <https://google-auth.readthedocs.io/en/latest/>`__ library for authentication because oauth2client is deprecated. (:issue:`39`)
- ``read_gbq`` now has a ``auth_local_webserver`` boolean argument for controlling whether to use web server or console flow when getting user credentials. Replaces `--noauth_local_webserver` command line argument. (:issue:`35`)
- ``read_gbq`` now displays the BigQuery Job ID in verbose output. (:issue:`70`)
- ``read_gbq`` now displays the BigQuery Job ID and standard price in verbose output. (:issue:`70` and :issue:`71`)

0.1.6 / 2017-05-03
------------------
Expand Down
8 changes: 7 additions & 1 deletion pandas_gbq/gbq.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,10 @@ def __init__(self, project_id, reauth=False, verbose=False,
self.credentials = self.get_credentials()
self.service = self.get_service()

# BQ Queries costs $5 per TB. First 1 TB per month is free
# see here for more: https://cloud.google.com/bigquery/pricing
self.query_price_for_TB = 5. / 2**40 # USD/TB

def get_credentials(self):
if self.private_key:
return self.get_service_account_credentials()
Expand Down Expand Up @@ -545,8 +549,10 @@ def run_query(self, query, **kwargs):
else:
bytes_processed = int(query_reply.get(
'totalBytesProcessed', '0'))
self._print('Query done.\nProcessed: {}\n'.format(
self._print('Query done.\nProcessed: {}'.format(
self.sizeof_fmt(bytes_processed)))
self._print('Standard price: ${:,.2f} USD\n'.format(
bytes_processed * self.query_price_for_TB))

self._print('Retrieving results...')

Expand Down