Skip to content

Commit 1707737

Browse files
authored
docs: build documentation with Sphinx (#97)
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/python-bigquery-sqlalchemy/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes #90 🦕
1 parent e9d66fb commit 1707737

File tree

6 files changed

+118
-66
lines changed

6 files changed

+118
-66
lines changed

CONTRIBUTING.md

-28
This file was deleted.

README.rst

+89-38
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,88 @@
1-
SQLAlchemy dialect and API client for BigQuery.
1+
SQLAlchemy Dialect for BigQuery
2+
===============================
23

4+
|beta| |pypi| |versions|
35

4-
Usage
5-
=====
6+
`SQLALchemy Dialects`_
7+
8+
- `Dialect Documentation`_
9+
- `Product Documentation`_
10+
11+
.. |beta| image:: https://img.shields.io/badge/support-beta-orange.svg
12+
:target: https://github.com/googleapis/google-cloud-python/blob/master/README.rst#beta-support
13+
.. |pypi| image:: https://img.shields.io/pypi/v/pybigquery.svg
14+
:target: https://pypi.org/project/pybigquery/
15+
.. |versions| image:: https://img.shields.io/pypi/pyversions/pybigquery.svg
16+
:target: https://pypi.org/project/pybigquery/
17+
.. _SQLAlchemy Dialects: https://docs.sqlalchemy.org/en/14/dialects/
18+
.. _Dialect Documentation: https://googleapis.dev/python/pybigquery/latest
19+
.. _Product Documentation: https://cloud.google.com/bigquery/docs/
20+
21+
22+
Quick Start
23+
-----------
24+
25+
In order to use this library, you first need to go through the following steps:
26+
27+
1. `Select or create a Cloud Platform project.`_
28+
2. [Optional] `Enable billing for your project.`_
29+
3. `Enable the BigQuery Storage API.`_
30+
4. `Setup Authentication.`_
31+
32+
.. _Select or create a Cloud Platform project.: https://console.cloud.google.com/project
33+
.. _Enable billing for your project.: https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project
34+
.. _Enable the BigQuery Storage API.: https://console.cloud.google.com/apis/library/bigquery.googleapis.com
35+
.. _Setup Authentication.: https://googleapis.dev/python/google-api-core/latest/auth.html
36+
37+
Installation
38+
------------
39+
40+
Install this library in a `virtualenv`_ using pip. `virtualenv`_ is a tool to
41+
create isolated Python environments. The basic problem it addresses is one of
42+
dependencies and versions, and indirectly permissions.
43+
44+
With `virtualenv`_, it's possible to install this library without needing system
45+
install permissions, and without clashing with the installed system
46+
dependencies.
47+
48+
.. _`virtualenv`: https://virtualenv.pypa.io/en/latest/
49+
50+
51+
Supported Python Versions
52+
^^^^^^^^^^^^^^^^^^^^^^^^^
53+
Python >= 3.6
54+
55+
Unsupported Python Versions
56+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
57+
Python <= 3.5.
58+
59+
60+
Mac/Linux
61+
^^^^^^^^^
62+
63+
.. code-block:: console
664
65+
pip install virtualenv
66+
virtualenv <your-env>
67+
source <your-env>/bin/activate
68+
<your-env>/bin/pip install pybigquery
69+
70+
71+
Windows
72+
^^^^^^^
73+
74+
.. code-block:: console
75+
76+
pip install virtualenv
77+
virtualenv <your-env>
78+
<your-env>\Scripts\activate
79+
<your-env>\Scripts\pip.exe install pybigquery
80+
81+
Usage
82+
-----
783

884
SQLAlchemy
9-
__________
85+
^^^^^^^^^^
1086

1187
.. code-block:: python
1288
@@ -18,7 +94,7 @@ __________
1894
print(select([func.count('*')], from_obj=table).scalar())
1995
2096
API Client
21-
__________
97+
^^^^^^^^^^
2298

2399
.. code-block:: python
24100
@@ -27,12 +103,12 @@ __________
27103
print(api_client.dry_run_query(query=sqlstr).total_bytes_processed)
28104
29105
Project
30-
_______
106+
^^^^^^^
31107

32108
``project`` in ``bigquery://project`` is used to instantiate BigQuery client with the specific project ID. To infer project from the environment, use ``bigquery://`` – without ``project``
33109

34110
Authentication
35-
______________
111+
^^^^^^^^^^^^^^
36112

37113
Follow the `Google Cloud library guide <https://google-cloud-python.readthedocs.io/en/latest/core/auth.html>`_ for authentication. Alternatively, you can provide the path to a service account JSON file in ``create_engine()``:
38114

@@ -42,7 +118,7 @@ Follow the `Google Cloud library guide <https://google-cloud-python.readthedocs.
42118
43119
44120
Location
45-
________
121+
^^^^^^^^
46122

47123
To specify location of your datasets pass ``location`` to ``create_engine()``:
48124

@@ -52,7 +128,7 @@ To specify location of your datasets pass ``location`` to ``create_engine()``:
52128
53129
54130
Table names
55-
___________
131+
^^^^^^^^^^^
56132

57133
To query tables from non-default projects or datasets, use the following format for the SQLAlchemy schema name: ``[project.]dataset``, e.g.:
58134

@@ -64,7 +140,7 @@ To query tables from non-default projects or datasets, use the following format
64140
sample_table_2 = Table('natality', schema='bigquery-public-data')
65141
66142
Batch size
67-
__________
143+
^^^^^^^^^^
68144

69145
By default, ``arraysize`` is set to ``5000``. ``arraysize`` is used to set the batch size for fetching results. To change it, pass ``arraysize`` to ``create_engine()``:
70146

@@ -74,7 +150,7 @@ By default, ``arraysize`` is set to ``5000``. ``arraysize`` is used to set the b
74150
75151
76152
Adding a Default Dataset
77-
________________________
153+
^^^^^^^^^^^^^^^^^^^^^^^^
78154

79155
If you want to have the ``Client`` use a default dataset, specify it as the "database" portion of the connection string.
80156

@@ -100,7 +176,7 @@ Note that specifying a default dataset doesn't restrict execution of queries to
100176
101177
102178
Connection String Parameters
103-
____________________________
179+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
104180

105181
There are many situations where you can't call ``create_engine`` directly, such as when using tools like `Flask SQLAlchemy <http://flask-sqlalchemy.pocoo.org/2.3/>`_. For situations like these, or for situations where you want the ``Client`` to have a `default_query_job_config <https://googlecloudplatform.github.io/google-cloud-python/latest/bigquery/generated/google.cloud.bigquery.client.Client.html#google.cloud.bigquery.client.Client>`_, you can pass many arguments in the query of the connection string.
106182

@@ -132,7 +208,7 @@ Here are examples of all the supported arguments. Any not present are either for
132208
133209
134210
Creating tables
135-
_______________
211+
^^^^^^^^^^^^^^^
136212

137213
To add metadata to a table:
138214

@@ -145,28 +221,3 @@ To add metadata to a column:
145221
.. code-block:: python
146222
147223
Column('mycolumn', doc='my column description')
148-
149-
150-
Requirements
151-
============
152-
153-
Install using
154-
155-
- ``pip install pybigquery``
156-
157-
158-
Testing
159-
============
160-
161-
Load sample tables::
162-
163-
./scripts/load_test_data.sh
164-
165-
This will create a dataset ``test_pybigquery`` with tables named ``sample_one_row`` and ``sample``.
166-
167-
Set up an environment and run tests::
168-
169-
pyvenv .env
170-
source .env/bin/activate
171-
pip install -r dev_requirements.txt
172-
pytest

docs/README.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../README.rst

docs/changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../CHANGELOG.md

docs/index.rst

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
.. include:: README.rst
2+
3+
.. include:: multiprocessing.rst
4+
5+
API Reference
6+
-------------
7+
.. toctree::
8+
:maxdepth: 2
9+
10+
pybigquery/api
11+
12+
Changelog
13+
---------
14+
15+
For a list of all ``pybigquery`` releases:
16+
17+
.. toctree::
18+
:maxdepth: 2
19+
20+
changelog

docs/pybigquery/api.rst

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PyBigQuery API
2+
==============
3+
4+
.. automodule:: pybigquery.api
5+
:members:
6+
:undoc-members:
7+
:inherited-members:

0 commit comments

Comments
 (0)