From cd589ab3c7b2f35774906c4001587550e8901ce2 Mon Sep 17 00:00:00 2001 From: Jesse Whitehouse Date: Mon, 27 Jun 2022 15:41:27 -0500 Subject: [PATCH 1/7] Add license and contributing sections to README. --- CONTRIBUTING.md | 13 +++++++++++++ README.md | 8 ++++++++ 2 files changed, 21 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..6cf2a2038 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,13 @@ +# Contributing + +To contribute to this repository, fork it and send pull requests. + +## Pull Request Process + +1. Update the [CHANGELOG.md](README.md) or similar documentation with details of changes you wish to make, if applicable. +2. Add any appropriate tests. +3. Make your code or other changes. +4. Review guidelines such as + [How to write the perfect pull request][github-perfect-pr], thanks! + +[github-perfect-pr]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/ \ No newline at end of file diff --git a/README.md b/README.md index f07233866..a5584883b 100644 --- a/README.md +++ b/README.md @@ -43,3 +43,11 @@ Where: - `` is the HTTP Path either to a Databricks SQL endpoint (e.g. /sql/1.0/endpoints/1234567890abcdef), or to a Databricks Runtime interactive cluster (e.g. /sql/protocolv1/o/1234567890123456/1234-123456-slid123) - `` is a HTTP Bearer access token, e.g. a Databricks Personal Access Token. + +## Contributing + +See [CONTRIBUTING.md](CONTRIBUTING.md) + +## License + +[Apache License 2.0](LICENSE) \ No newline at end of file From 0c86ff6f44050805ca33b662cccb30996339992c Mon Sep 17 00:00:00 2001 From: Jesse Whitehouse Date: Mon, 27 Jun 2022 15:51:52 -0500 Subject: [PATCH 2/7] Add environment setup docs to CONTRIBUTING --- CONTRIBUTING.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6cf2a2038..e6028a4ce 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,6 +2,33 @@ To contribute to this repository, fork it and send pull requests. +## Set up your environment + +This project uses [Poetry](https://python-poetry.org/) for dependency management, tests, and linting. + +1. Clone this respository +2. Run `poetry install` + +### Unit Tests + +#### All tests +```bash +poetry run pytest tests +``` + +#### Specific tests + +```bash +poetry run pytest tests/path/to/test.py +``` + +### Code formatting + +This project uses [Black](https://pypi.org/project/black/). + +``` +poetry run black src +``` ## Pull Request Process 1. Update the [CHANGELOG.md](README.md) or similar documentation with details of changes you wish to make, if applicable. From 1ddd597c25ec539ec64f37864a2e1bf3177fc2ee Mon Sep 17 00:00:00 2001 From: Jesse Whitehouse Date: Mon, 27 Jun 2022 15:58:12 -0500 Subject: [PATCH 3/7] Clarify example of connection details in example --- README.md | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index a5584883b..5ec75bd55 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,10 @@ Example usage: from databricks import sql connection = sql.connect( - server_hostname='', - http_path='', - access_token='') + server_hostname='********.databricks.com', + http_path='/sql/1.0/endpoints/****************', + access_token='dapi********************************') + cursor = connection.cursor() @@ -38,11 +39,12 @@ cursor.close() connection.close() ``` -Where: -- `` is the Databricks instance host name. -- `` is the HTTP Path either to a Databricks SQL endpoint (e.g. /sql/1.0/endpoints/1234567890abcdef), - or to a Databricks Runtime interactive cluster (e.g. /sql/protocolv1/o/1234567890123456/1234-123456-slid123) -- `` is a HTTP Bearer access token, e.g. a Databricks Personal Access Token. +In the above example: +- `server-hostname` is the Databricks instance host name. +- `http-path` is the HTTP Path either to a Databricks SQL endpoint (e.g. /sql/1.0/endpoints/1234567890abcdef), +or to a Databricks Runtime interactive cluster (e.g. /sql/protocolv1/o/1234567890123456/1234-123456-slid123) +- `personal-access-token` is the Databricks Personal Access Token for the account that will execute commands and queries + ## Contributing From 1fd42764b72cb3a8a0e6a02061154c2b93403d57 Mon Sep 17 00:00:00 2001 From: Jesse Date: Mon, 27 Jun 2022 16:14:51 -0500 Subject: [PATCH 4/7] Add badges from pypi I couldn't add supported python versions. Poetry doesn't provide the correct trove classifiers based on our current Python specification. If this is important we can add it later. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ec75bd55..cbd5bb478 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ # Databricks SQL Connector for Python +[![PyPI](https://img.shields.io/pypi/v/databricks-sql-connector?style=flat-square)](https://pypi.org/project/databricks-sql-connector/) +[![Downloads](https://pepy.tech/badge/databricks-sql-connector)](https://pepy.tech/project/databricks-sql-connector) + The Databricks SQL Connector for Python allows you to develop Python applications that connect to Databricks clusters and SQL warehouses. It is a Thrift-based client with no dependencies on ODBC or JDBC. It conforms to the [Python DB API 2.0 specification](https://www.python.org/dev/peps/pep-0249/). This connector uses Arrow as the data-exchange format, and supports APIs to directly fetch Arrow tables. Arrow tables are wrapped in the `ArrowQueue` class to provide a natural API to get several rows at a time. @@ -52,4 +55,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) ## License -[Apache License 2.0](LICENSE) \ No newline at end of file +[Apache License 2.0](LICENSE) From dde1e3f5f0428d5eefb882a4a4762c55f817262c Mon Sep 17 00:00:00 2001 From: Jesse Date: Mon, 27 Jun 2022 17:01:38 -0500 Subject: [PATCH 5/7] Explicitly call out Python 3.7 or above is needed --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cbd5bb478..45251507f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,11 @@ This connector uses Arrow as the data-exchange format, and supports APIs to dire You are welcome to file an issue here for general use cases. You can also contact Databricks Support [here](help.databricks.com). -# Documentation +## Requirements + +Python 3.7 or above is required. + +## Documentation For the latest documentation, see From 22bbd22f8457497aa7a9bc1362b1d1063387391c Mon Sep 17 00:00:00 2001 From: Jesse Date: Mon, 27 Jun 2022 17:06:35 -0500 Subject: [PATCH 6/7] Clarify unit test invocation command --- CONTRIBUTING.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e6028a4ce..64351b1c7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,15 +11,23 @@ This project uses [Poetry](https://python-poetry.org/) for dependency management ### Unit Tests +We use [Pytest]([url](https://docs.pytest.org/en/7.1.x/)) as our test runner. Invoke it with `poetry run pytest`, all other arguments are passed directly to `pytest`. + #### All tests ```bash poetry run pytest tests ``` -#### Specific tests +#### Only a specific test file + +```bash +poetry run pytest tests/tests.py +``` + +#### Only a specific method ```bash -poetry run pytest tests/path/to/test.py +poetry run pytest tests/tests.py::ClientTestSuite::test_closing_connection_closes_commands ``` ### Code formatting @@ -37,4 +45,4 @@ poetry run black src 4. Review guidelines such as [How to write the perfect pull request][github-perfect-pr], thanks! -[github-perfect-pr]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/ \ No newline at end of file +[github-perfect-pr]: https://blog.github.com/2015-01-21-how-to-write-the-perfect-pull-request/ From 83c4753bf7e5c9ef14b66422683eee1293b94905 Mon Sep 17 00:00:00 2001 From: Jesse Date: Mon, 27 Jun 2022 17:07:01 -0500 Subject: [PATCH 7/7] Fix bad link --- CONTRIBUTING.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 64351b1c7..bd4886df2 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -11,7 +11,7 @@ This project uses [Poetry](https://python-poetry.org/) for dependency management ### Unit Tests -We use [Pytest]([url](https://docs.pytest.org/en/7.1.x/)) as our test runner. Invoke it with `poetry run pytest`, all other arguments are passed directly to `pytest`. +We use [Pytest](https://docs.pytest.org/en/7.1.x/) as our test runner. Invoke it with `poetry run pytest`, all other arguments are passed directly to `pytest`. #### All tests ```bash