Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit 43a2741

Browse files
authored
doc: add example to README (#27)
1 parent 3d9b2cb commit 43a2741

File tree

3 files changed

+85
-6
lines changed

3 files changed

+85
-6
lines changed

README.md

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

README.rst

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
Ibis BigQuery backend
2+
=====================
3+
4+
This package provides a [BigQuery](https://cloud.google.com/bigquery) backend
5+
for [Ibis](https://ibis-project.org/).
6+
7+
Installation
8+
------------
9+
10+
Supported Python Versions
11+
^^^^^^^^^^^^^^^^^^^^^^^^^
12+
Python >= 3.7, < 3.10
13+
14+
Unsupported Python Versions
15+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
Python < 3.7
17+
18+
Install with conda:
19+
20+
.. code-block:: console
21+
22+
conda install -c conda-forge ibis-bigquery
23+
24+
Install with pip:
25+
26+
.. code-block:: console
27+
28+
pip install ibis-bigquery
29+
30+
Usage
31+
-----
32+
33+
Connecting to BigQuery
34+
^^^^^^^^^^^^^^^^^^^^^^
35+
36+
Recommended usage:
37+
38+
.. code-block:: python
39+
40+
import ibis
41+
42+
conn = ibis.bigquery.connect(
43+
project_id=YOUR_PROJECT_ID,
44+
dataset_id='bigquery-public-data.stackoverflow'
45+
)
46+
47+
Using this library directly:
48+
49+
.. code-block:: python
50+
51+
import ibis
52+
import ibis_bigquery
53+
54+
conn = ibis_bigquery.Backend().connect(
55+
project_id=YOUR_PROJECT_ID,
56+
dataset_id='bigquery-public-data.stackoverflow'
57+
)
58+
59+
Running a query
60+
^^^^^^^^^^^^^^^
61+
62+
.. code-block:: python
63+
64+
edu_table = conn.table(
65+
'international_education',
66+
database='bigquery-public-data.world_bank_intl_education')
67+
edu_table = edu_table['value', 'year', 'country_code', 'indicator_code']
68+
69+
country_table = conn.table(
70+
'country_code_iso',
71+
database='bigquery-public-data.utility_us')
72+
country_table = country_table['country_name', 'alpha_3_code']
73+
74+
expression = edu_table.join(
75+
country_table,
76+
[edu_table.country_code == country_table.alpha_3_code])
77+
78+
print(conn.execute(
79+
expression[edu_table.year == 2016]
80+
# Adult literacy rate.
81+
[edu_table.indicator_code == 'SE.ADT.LITR.ZS']
82+
.sort_by([ibis.desc(edu_table.value)])
83+
.limit(20)
84+
))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
setuptools.setup(
1010
name='ibis-bigquery',
1111
description='Ibis BigQuery backend',
12-
long_description=open(os.path.join(BASE_PATH, 'README.md')).read(),
12+
long_description=open(os.path.join(BASE_PATH, 'README.rst')).read(),
1313
url='https://github.com/ibis-project/ibis-bigquery',
1414
packages=setuptools.find_packages(),
1515
python_requires='>=3.7',

0 commit comments

Comments
 (0)