Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .env

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
# .github/workflows/python-self-hosted.yml
name: Python CI (Self-hosted)
# .github/workflows/python-ci.yml
name: Python CI

on:
push:
branches: [ "main" ]
branches: [ "main", "dev" ]
pull_request:
branches: [ "main" ]
branches: [ "main", "dev" ]

jobs:
build:
runs-on: self-hosted
runs-on: ubuntu-latest

env:
DATASTORE_EMULATOR_HOST: "localhost:8081"

steps:
- name: Checkout code
Expand All @@ -19,13 +22,25 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.13'


- name: Set up Java (required for Datastore emulator)
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'

- name: 'Set up Cloud SDK'
uses: 'google-github-actions/setup-gcloud@v2'
with:
install_components: 'cloud-datastore-emulator'
install_components: 'beta,cloud-datastore-emulator'

- name: 'Verify gcloud setup'
run: |
gcloud --version
which gcloud
gcloud components list --filter="id:cloud-datastore-emulator" --format="table(id,state.name)"

- name: 'Use gcloud CLI'
- name: 'Configure gcloud project'
run: 'gcloud config set project python-datastore-sqlalchemy'

- name: Install dependencies
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ print(result.fetchall())
## Preview
<img src="assets/pie.png">

## How to contribute
Feel free to open issues and pull requests on github.

## References
- [Develop a SQLAlchemy dialects](https://hackmd.io/lsBW5GCVR82SORyWZ1cssA?view)
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.ruff]
line-length = 120

[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "B", "C", "G", "S"]
ignore = [
"E501", # Line too long - allow longer lines for SQL strings in tests
"S608", # SQL injection - intentional for test cases
"B007", # Loop variable not used - common in test assertions
]

[tool.ruff.lint.per-file-ignores]
"tests/*" = ["S608", "E501", "S101", "B007", "S603"]

[tool.mypy]
ignore_missing_imports = true
disable_error_code = ["var-annotated", "import-untyped"]

[[tool.mypy.overrides]]
module = ["tests.*", "sqlalchemy_datastore.*"]
ignore_errors = true
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pytest-cov==6.2.1
pytest-html==4.1.1
pytest-mypy==1.0.1
pytest-ruff==0.5
pytest-dotenv==0.5.2
flake8==7.3.0
coverage==7.9.2
sqlglotrs==0.6.2
pandas==2.3.3
sqlglot==28.6.0
10 changes: 7 additions & 3 deletions sqlalchemy_datastore/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ class CloudDatastoreDialect(default.DefaultDialect):
returns_unicode_strings = True
description_encoding = None

# JSON support - required for SQLAlchemy JSON type
_json_serializer = None
_json_deserializer = None

paramstyle = "named"

def __init__(
Expand Down Expand Up @@ -256,13 +260,13 @@ def _contains_select_subquery(self, node) -> bool:
def do_execute(
self,
cursor,
# cursor: DBAPICursor, TODO: Uncomment when superset allow sqlalchemy version >= 2.0
# cursor: DBAPICursor, TODO: Uncomment when superset allow sqlalchemy version >= 2.0
statement: str,
# parameters: Optional[], TODO: Uncomment when superset allow sqlalchemy version >= 2.0
# parameters: Optional[], TODO: Uncomment when superset allow sqlalchemy version >= 2.0
parameters,
context: Optional[ExecutionContext] = None,
) -> None:
cursor.execute(statement)
cursor.execute(statement, parameters)

def get_view_names(
self, connection: Connection, schema: str | None = None, **kw: Any
Expand Down
Loading
Loading