-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6bd9c80
commit 14579e4
Showing
76 changed files
with
666 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[settings] | ||
profile = black | ||
known_first_party = shillelagh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,95 @@ | ||
exclude: '^docs/conf.py' | ||
|
||
repos: | ||
- repo: https://github.com/ambv/black | ||
rev: 21.6b0 | ||
hooks: | ||
- id: black | ||
language_version: python3.9 | ||
exclude: ^templates/ | ||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
exclude: ^templates/ | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: 'v0.910' # Use the sha / tag you want to point at | ||
hooks: | ||
- id: mypy | ||
exclude: ^templates/ | ||
additional_dependencies: | ||
- types-requests | ||
- types-freezegun | ||
- types-python-dateutil | ||
- types-pkg_resources | ||
- types-PyYAML | ||
- types-tabulate | ||
- repo: https://github.com/asottile/add-trailing-comma | ||
rev: v2.1.0 | ||
hooks: | ||
- id: add-trailing-comma | ||
exclude: ^templates/ | ||
- repo: https://github.com/asottile/reorder_python_imports | ||
rev: v2.5.0 | ||
hooks: | ||
- id: reorder-python-imports | ||
exclude: ^templates/ | ||
args: [--application-directories=.:src] | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.0.1 | ||
hooks: | ||
- id: debug-statements | ||
exclude: ^templates/ | ||
- repo: git://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: trailing-whitespace | ||
- id: check-added-large-files | ||
- id: check-ast | ||
exclude: ^templates/ | ||
- id: check-json | ||
- id: check-merge-conflict | ||
- id: check-xml | ||
- id: check-yaml | ||
- id: debug-statements | ||
exclude: ^templates/ | ||
- id: end-of-file-fixer | ||
- id: requirements-txt-fixer | ||
exclude: ^templates/ | ||
- id: mixed-line-ending | ||
args: ['--fix=auto'] # replace 'auto' with 'lf' to enforce Linux/Mac line endings or 'crlf' for Windows | ||
|
||
## If you want to avoid flake8 errors due to unused vars or imports: | ||
# - repo: https://github.com/myint/autoflake.git | ||
# rev: v1.4 | ||
# hooks: | ||
# - id: autoflake | ||
# args: [ | ||
# --in-place, | ||
# --remove-all-unused-imports, | ||
# --remove-unused-variables, | ||
# ] | ||
|
||
- repo: https://github.com/pycqa/isort | ||
rev: 5.7.0 | ||
hooks: | ||
- id: isort | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 20.8b1 | ||
hooks: | ||
- id: black | ||
language_version: python3 | ||
exclude: ^templates/ | ||
|
||
## If like to embrace black styles even in the docs: | ||
# - repo: https://github.com/asottile/blacken-docs | ||
# rev: v1.9.1 | ||
# hooks: | ||
# - id: blacken-docs | ||
# additional_dependencies: [black] | ||
|
||
- repo: https://gitlab.com/pycqa/flake8 | ||
rev: 3.9.2 | ||
hooks: | ||
- id: flake8 | ||
exclude: ^templates/ | ||
## You can add flake8 plugins via `additional_dependencies`: | ||
# additional_dependencies: [flake8-bugbear] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: 'v0.910' # Use the sha / tag you want to point at | ||
hooks: | ||
- id: mypy | ||
exclude: ^templates/ | ||
additional_dependencies: | ||
- types-requests | ||
- types-freezegun | ||
- types-python-dateutil | ||
- types-pkg_resources | ||
- types-PyYAML | ||
- types-tabulate | ||
- repo: https://github.com/asottile/add-trailing-comma | ||
rev: v2.1.0 | ||
hooks: | ||
- id: add-trailing-comma | ||
#- repo: https://github.com/asottile/reorder_python_imports | ||
# rev: v2.5.0 | ||
# hooks: | ||
# - id: reorder-python-imports | ||
# args: [--application-directories=.:src] | ||
- repo: https://github.com/hadialqattan/pycln | ||
rev: v1.0.3 # Possible releases: https://github.com/hadialqattan/pycln/tags | ||
hooks: | ||
- id: pycln | ||
args: [--config=pyproject.toml] | ||
exclude: ^templates/ | ||
- id: pycln | ||
args: [--config=pyproject.toml] | ||
exclude: ^templates/ | ||
- repo: local | ||
hooks: | ||
- id: pylint | ||
name: pylint | ||
entry: pylint | ||
language: system | ||
types: [python] | ||
exclude: ^templates/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
[MESSAGES CONTROL] | ||
disable = | ||
duplicate-code | ||
|
||
[MASTER] | ||
ignore=templates,docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,14 +22,14 @@ The DB API 2.0 specification defines standard mechanisms to create database conn | |
query = "CREATE TABLE a_table (A int, B string)" | ||
cursor.execute(query) | ||
query = "INSERT INTO a_table VALUES (?, ?)" | ||
cursor.execute(query, (1, "one")) | ||
cursor.execute(query, (2, "two")) | ||
query = "SELECT * FROM a_table" | ||
for row in cursor.execute(query): | ||
print(row) | ||
print(row) | ||
You can use a file instead of ``:memory:``: | ||
|
||
|
@@ -120,7 +120,7 @@ The SQLAlchemy engine can be configured in the same way as the :ref:`dbapi2` ``c | |
Alternatively, Shillelagh also comes with a custom Google Sheets dialect for SQLAlchemy. See :ref:`gsheets` for more details. | ||
|
||
|
||
Command-line utility | ||
==================== | ||
|
||
|
@@ -153,7 +153,7 @@ The command-line utility can be configured through a YAML file stored in ``~/.co | |
subject: [email protected] | ||
weatherapi: | ||
api_key: XXX | ||
Custom functions | ||
================ | ||
|
||
|
@@ -198,4 +198,4 @@ Sometimes it's useful to identify the version of Shillelagh that's running on a | |
sql> SELECT VERSION(); | ||
VERSION() | ||
----------- | ||
1.0.0 | ||
1.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,39 @@ | ||
""" | ||
A simple example showing the CSV adapter. | ||
""" | ||
from shillelagh.backends.apsw.db import connect | ||
|
||
if __name__ == "__main__": | ||
connection = connect(":memory:") | ||
cursor = connection.cursor() | ||
|
||
sql = '''SELECT * FROM "test.csv"''' | ||
print(sql) | ||
for row in cursor.execute(sql): | ||
SQL = '''SELECT * FROM "test.csv"''' | ||
print(SQL) | ||
for row in cursor.execute(SQL): | ||
print(row) | ||
print("==") | ||
|
||
sql = """SELECT * FROM "test.csv" WHERE "index" > 11""" | ||
print(sql) | ||
for row in cursor.execute(sql): | ||
SQL = """SELECT * FROM "test.csv" WHERE "index" > 11""" | ||
print(SQL) | ||
for row in cursor.execute(SQL): | ||
print(row) | ||
print("==") | ||
|
||
sql = """INSERT INTO "test.csv" ("index", temperature, site) VALUES (14, 10.1, 'New_Site')""" | ||
print(sql) | ||
cursor.execute(sql) | ||
SQL = """INSERT INTO "test.csv" ("index", temperature, site) VALUES (14, 10.1, 'New_Site')""" | ||
print(SQL) | ||
cursor.execute(SQL) | ||
|
||
sql = """SELECT * FROM "test.csv" WHERE "index" > 11""" | ||
print(sql) | ||
for row in cursor.execute(sql): | ||
SQL = """SELECT * FROM "test.csv" WHERE "index" > 11""" | ||
print(SQL) | ||
for row in cursor.execute(SQL): | ||
print(row) | ||
print("==") | ||
|
||
sql = """DELETE FROM "test.csv" WHERE site = 'New_Site'""" | ||
print(sql) | ||
cursor.execute(sql) | ||
sql = '''SELECT * FROM "test.csv"''' | ||
print(sql) | ||
for row in cursor.execute(sql): | ||
SQL = """DELETE FROM "test.csv" WHERE site = 'New_Site'""" | ||
print(SQL) | ||
cursor.execute(SQL) | ||
SQL = '''SELECT * FROM "test.csv"''' | ||
print(SQL) | ||
for row in cursor.execute(SQL): | ||
print(row) | ||
print("==") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
""" | ||
A simple example showing the Pandas adapter. | ||
""" | ||
import pandas as pd | ||
|
||
from shillelagh.backends.apsw.db import connect | ||
|
||
|
||
if __name__ == "__main__": | ||
connection = connect(":memory:") | ||
cursor = connection.cursor() | ||
|
||
mydf = pd.DataFrame({"a": [1, 2, 3]}) | ||
|
||
sql = "SELECT SUM(a) FROM mydf" | ||
for row in cursor.execute(sql): | ||
SQL = "SELECT SUM(a) FROM mydf" | ||
for row in cursor.execute(SQL): | ||
print(row) | ||
|
||
sql = "UPDATE mydf SET a = a + 1" | ||
cursor.execute(sql) | ||
SQL = "UPDATE mydf SET a = a + 1" | ||
cursor.execute(SQL) | ||
|
||
sql = "SELECT SUM(a) FROM mydf" | ||
for row in cursor.execute(sql): | ||
SQL = "SELECT SUM(a) FROM mydf" | ||
for row in cursor.execute(SQL): | ||
print(row) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.