Mock Redshift locally by transpiling Redshift SQL to DuckDB and running it.
Project description
rs-mock
A super lightweight, in-process Redshift mocker for test suites.
rs-mock transpiles Redshift SQL to duckdb SQL with sqlglot and runs it against an in-memory duckdb database. No cluster, no network, no Docker — just fast, in-process SQL.
Usage
from rs_mock import RedshiftMock
rs = RedshiftMock()
# DDL / DML — state persists across calls for the instance's lifetime
rs.execute("CREATE TABLE users (id INT, name VARCHAR)")
rs.execute("INSERT INTO users VALUES (1, 'alice'), (2, 'bob')")
# SELECTs, JOINs, CTEs — execute() returns the duckdb cursor
rows = rs.execute("SELECT id, name FROM users ORDER BY id").fetchall()
# [(1, 'alice'), (2, 'bob')]
# Need duckdb power features? Grab the cursor or the connection.
df = rs.execute("SELECT * FROM users").df()
rs.connection # the underlying duckdb connection
Supported: regular selects, joins, CTEs, and DDL/DML. Redshift-specific syntax
(e.g. GETDATE()) is rewritten to its duckdb equivalent automatically.
S3: UNLOAD and COPY
UNLOAD and COPY ... FROM 's3://...' are supported against real S3 or, in
tests, a moto-mocked bucket — no cluster and
no network. Install the extra (pip install 'rs-mock[s3]') to pull in boto3,
then run UNLOAD/COPY like any other statement inside a mock_aws context:
import boto3
from moto import mock_aws
from rs_mock import RedshiftMock
with mock_aws():
boto3.client("s3").create_bucket(Bucket="my-bucket")
rs = RedshiftMock()
rs.execute("CREATE TABLE users (id INT, name VARCHAR)")
rs.execute("INSERT INTO users VALUES (1, 'alice'), (2, 'bob')")
# Query result -> S3 (CSV, PARQUET, JSON, or default pipe-delimited text)
rs.execute(
"UNLOAD ('SELECT * FROM users') TO 's3://my-bucket/users_' "
"IAM_ROLE 'arn:aws:iam::123:role/r' FORMAT AS PARQUET"
)
# S3 -> table (every object under the prefix is loaded)
rs.execute("CREATE TABLE loaded (id INT, name VARCHAR)")
rs.execute(
"COPY loaded FROM 's3://my-bucket/users_' "
"IAM_ROLE 'arn:aws:iam::123:role/r' FORMAT AS PARQUET"
)
Recognized options: UNLOAD FORMAT AS {CSV|PARQUET|JSON}, DELIMITER,
HEADER; COPY FORMAT AS {CSV|PARQUET|JSON}, DELIMITER, IGNOREHEADER, and a
column list. Authorization (IAM_ROLE/CREDENTIALS) is parsed but ignored —
boto3's own credential resolution (or moto) applies.
Development
make test # run tests
make lint # ruff + pyrefly
make prek # pre-commit hooks
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rs_mock-0.2.0.tar.gz.
File metadata
- Download URL: rs_mock-0.2.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17865748ed96a1f6abe53d338fe8dd6b548e86396df150b48efa59afd227db13
|
|
| MD5 |
a2ed504b97a2c743540bccbbf4d510ec
|
|
| BLAKE2b-256 |
fbe6d1937cb4a72a09dd1f8857be8da689f1e3e0a5db426116d2bfbb7d91e256
|
Provenance
The following attestation bundles were made for rs_mock-0.2.0.tar.gz:
Publisher:
release-please.yml on tylerriccio33/rs-mock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rs_mock-0.2.0.tar.gz -
Subject digest:
17865748ed96a1f6abe53d338fe8dd6b548e86396df150b48efa59afd227db13 - Sigstore transparency entry: 2132812413
- Sigstore integration time:
-
Permalink:
tylerriccio33/rs-mock@cffc6a2a488e09f0b66379c7febb960542c50361 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tylerriccio33
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@cffc6a2a488e09f0b66379c7febb960542c50361 -
Trigger Event:
push
-
Statement type:
File details
Details for the file rs_mock-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rs_mock-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3637af4191e9593d3e602de49095c7397f8345c77ae45d2cfe2cef9be40f23b4
|
|
| MD5 |
a3a2ab3d2e2e38d8e65efbe5238127d3
|
|
| BLAKE2b-256 |
c18e32c386addf623d0b6fa6e7d6130bec066097c26eafe783dc46c2760e41ae
|
Provenance
The following attestation bundles were made for rs_mock-0.2.0-py3-none-any.whl:
Publisher:
release-please.yml on tylerriccio33/rs-mock
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rs_mock-0.2.0-py3-none-any.whl -
Subject digest:
3637af4191e9593d3e602de49095c7397f8345c77ae45d2cfe2cef9be40f23b4 - Sigstore transparency entry: 2132812537
- Sigstore integration time:
-
Permalink:
tylerriccio33/rs-mock@cffc6a2a488e09f0b66379c7febb960542c50361 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/tylerriccio33
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@cffc6a2a488e09f0b66379c7febb960542c50361 -
Trigger Event:
push
-
Statement type: