Skip to content

Instantly share code, notes, and snippets.

View amotl's full-sized avatar

Andreas Motl amotl

  • $PYTHONPATH
View GitHub Profile
@amotl
amotl / bug1000.py
Created March 27, 2025 21:15
Limit of total columns [1000] in table [doc.total1000] exceeded
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.9"
# dependencies = [
# "sqlalchemy-cratedb",
# ]
# ///
"""
Usage:
@amotl
amotl / cratedb_sqlalchemy_connect.py
Last active February 13, 2025 20:19
Validate CrateDB SQLAlchemy connect timeout
import sqlalchemy as sa
TIMEOUT = 0.00001
if __name__ == "__main__":
engine = sa.create_engine('crate://localhost/', connect_args={"timeout": TIMEOUT})
c = engine.connect()
result = c.execute(sa.text("SELECT 42;"))
print(result.all())
@amotl
amotl / transfer_pull_requests.py
Last active February 10, 2025 23:50
Transfer pull requests from one repository to another
"""
# Transfer GitHub Pull Requests
## About
Transfer pull requests on GitHub from one repository to another.
## Details
Here: Transfer PRs closed by stale bot on the PyCaret repository,
modulo updates submitted by Dependabot, to the fork at sktime.
@amotl
amotl / acquire_dataset_cached.py
Last active January 19, 2025 03:09
Concisely fetch data from remote resources in Python, with caching
#!/usr/bin/env python
"""
## About
Concisely fetch data from remote resources in Python, with caching.
## Synopsis
```
uv run acquire_dataset_cached.py
```
@amotl
amotl / Universal_Declaration_of_Human_Rights.md
Created December 24, 2024 23:39
Universal Declaration of Human Rights
@amotl
amotl / cratedb-ecosystem-build-failures.sh
Last active December 7, 2024 05:07
Enumerate recent build failures in repositories relevant for CrateDB's ecosystem
# GitHub Actions Workflow Failures Digest for CrateDB's ecosystem
# https://github.com/crate/crate-clients-tools/issues/148
# Optionally use authentication when running into rate limits.
# It is an (here invalidated) personal access token (classic),
# using the "workflow" scope.
# GITHUB_TOKEN=ghp_00r4G0tGxLDT5RGOwWNw7tZhFnK5fT0uMfoo
# HTTPIE_OPTIONS="--auth-type bearer --auth ${GITHUB_TOKEN}"
@amotl
amotl / cratedb-sqlalchemy-active-servers.py
Created July 1, 2024 16:24
Access list of active server connections to CrateDB when using SQLAlchemy
# Connect using SQLAlchemy Core.
import sqlalchemy as sa
from pprint import pp
dburi = "crate://localhost:4200"
query = "SELECT country, mountain, coordinates, height FROM sys.summits ORDER BY country;"
def print_active_servers(connection: sa.engine.Connection):
print("Active Servers:", connection.connection.dbapi_connection.client.active_servers)
@amotl
amotl / cratedb_heap_exhaust_weird_error.py
Last active June 11, 2024 23:55
Attempt to trip a low-memory condition in CrateDB, resulting in a weird error message.
"""
Attempt to trip a low-memory condition in CrateDB, resulting in a weird error message
like `SQLParseException[ShardCollectContext for 0 already added]`.
This program tries to emulate the MLflow test case `test_search_runs_returns_expected_results_with_large_experiment`,
succeeded by a `DELETE FROM` table truncation operation.
Remark: It did not work out well. This program trips `OutOfMemoryError[Java heap space]`
right away. Please use the MLflow test case reproducer demonstrated at:
https://github.com/crate-workbench/mlflow-cratedb/issues/53#issuecomment-1927234463
@amotl
amotl / cratedb_regression_15488.py
Created January 30, 2024 00:38
CrateDB error: The assembled list of ParameterSymbols is invalid. Missing parameters.
"""
## About
Regression with CrateDB nightly-5.7.0-2024-01-26-00-02.
The assembled list of ParameterSymbols is invalid. Missing parameters.
-- https://github.com/crate/crate/issues/15488
## Setup
@amotl
amotl / update-from-merges.sql
Created December 16, 2023 22:05
Demo: SQL "UPDATE ... FROM" for upsert/merge operations. Reflecting Meltano's PostgreSQL data loader (target) adapter.
-- Demo: SQL "UPDATE ... FROM" for upsert/merge operations.
-- Reflecting Meltano's PostgreSQL data loader (target) adapter.
--
-- Usage:
--
-- psql postgresql://postgres@localhost:5432/ < update-from-merges.sql
-- crash --host http://crate@localhost:4200/ < update-from-merges.sql
-- Make a blank slate.
DROP TABLE IF EXISTS main;