Skip to content

Commit

Permalink
ENH: query standard price (USD) presentation (googleapis#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
tworec authored Jul 12, 2017
1 parent 269685c commit 964a19b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 964a19b

Please sign in to comment.