Skip to content

Commit

Permalink
Merge pull request #4 from erezsh/dev
Browse files Browse the repository at this point in the history
Various updates
  • Loading branch information
erezsh authored Jun 14, 2024
2 parents 01defb3 + 46d222d commit 29b8e32
Show file tree
Hide file tree
Showing 10 changed files with 671 additions and 704 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Build the stack
run: docker-compose up -d mysql postgres presto trino clickhouse vertica
run: docker-compose up -d mysql postgres trino clickhouse vertica

- name: Install Poetry
run: pip install poetry
Expand All @@ -42,7 +42,7 @@ jobs:

- name: Run unit tests
env:
PRESTO_URI: 'presto://presto@127.0.0.1/postgresql/public'
# PRESTO_URI: 'presto://presto@127.0.0.1/postgresql/public'
TRINO_URI: 'trino://postgres@127.0.0.1:8081/postgresql/public'
CLICKHOUSE_URI: 'clickhouse://clickhouse:Password1@localhost:9000/clickhouse'
VERTICA_URI: 'vertica://vertica:Password1@localhost:5433/vertica'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci_full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
python-version: ${{ matrix.python-version }}

- name: Build the stack
run: docker-compose up -d mysql postgres presto trino clickhouse vertica
run: docker-compose up -d mysql postgres trino clickhouse vertica

- name: Install Poetry
run: pip install poetry
Expand All @@ -40,7 +40,7 @@ jobs:

- name: Run unit tests
env:
PRESTO_URI: 'presto://presto@127.0.0.1/postgresql/public'
# PRESTO_URI: 'presto://presto@127.0.0.1/postgresql/public'
TRINO_URI: 'trino://postgres@127.0.0.1:8081/postgresql/public'
CLICKHOUSE_URI: 'clickhouse://clickhouse:Password1@localhost:9000/clickhouse'
VERTICA_URI: 'vertica://vertica:Password1@localhost:5433/vertica'
Expand Down
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ services:
image: mysql:oracle
# fsync less aggressively for insertion perf for test setup
command: >
--default-authentication-plugin=mysql_native_password
--binlog-cache-size=16M
--key_buffer_size=0
--max_connections=1000
Expand Down
10 changes: 9 additions & 1 deletion docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ Note: Some shells use `"` for escaping instead, like:
pip install "sqeleton[mysql, postgresql]"
```

### Postgresql + Debian

Before installing the postgresql driver, ensure you have libpq-dev:

```bash
apt-get install libpq-dev
```

## Connection editor

Sqeleton provides a TUI connection editor, that can be installed using:
Expand All @@ -55,4 +63,4 @@ Read more [here](conn_editor.md).

## What's next?

Read the [introduction](intro.md) and start coding!
Read the [introduction](intro.md) and start coding!
1,326 changes: 641 additions & 685 deletions poetry.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ authors = ["Erez Shinan <erezshin@gmail.com>"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/erezsh/sqeleton"
documentation = ""
documentation = "https://sqeleton.readthedocs.io/en/latest/"
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
Expand All @@ -23,7 +23,7 @@ packages = [{ include = "sqeleton" }]

[tool.poetry.dependencies]
python = "^3.8"
runtype = "^0.3.5"
runtype = "^0.4.2"
dsnparse = "*"
click = "^8.1"
rich = "*"
Expand All @@ -45,7 +45,7 @@ prompt-toolkit = {version="^3.0.36", optional=true}
parameterized = "*"
unittest-parallel = "*"

duckdb = "^0.7.0"
duckdb = "*"
mysql-connector-python = "*"
psycopg2 = "*"
snowflake-connector-python = "^2.7.2"
Expand Down
3 changes: 2 additions & 1 deletion sqeleton/databases/presto.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ def parse_type(
return super().parse_type(table_path, col_name, type_repr, datetime_precision, numeric_precision)

def set_timezone_to_utc(self) -> str:
return "SET TIME ZONE '+00:00'"
# return "SET TIME ZONE '+00:00'"
raise NotImplementedError("TODO")

def current_timestamp(self) -> str:
return "current_timestamp"
Expand Down
2 changes: 2 additions & 0 deletions sqeleton/databases/trino.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ class Dialect(presto.Dialect):
name = "Trino"
ARG_SYMBOL = "?"

def set_timezone_to_utc(self) -> str:
return "SET TIME ZONE '+00:00'"

class Trino(presto.Presto):
dialect = Dialect()
Expand Down
7 changes: 6 additions & 1 deletion sqeleton/queries/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from ..utils import ArithString
from ..abcs import AbstractDatabase, AbstractDialect, DbPath, AbstractCompiler, Compilable
from .base import SKIP


cv_params = contextvars.ContextVar("params")
Expand Down Expand Up @@ -87,6 +88,8 @@ def compile_with_args(self, elem: Any, params: Optional[Dict[str, Any]] = None)
self = self.replace(_args_enabled=True)

res = self.compile(elem, params)
if res is SKIP:
return SKIP

if self._args:
res, args = eval_template(res, self._args, self.dialect.ARG_SYMBOL)
Expand Down Expand Up @@ -119,8 +122,10 @@ def _compile(self, elem) -> str:
return f"'{elem}'"
elif isinstance(elem, ArithString):
return f"'{elem}'"
elif isinstance(elem, (str, bytes, bytearray)):
elif isinstance(elem, str):
return self._add_as_param(elem)
elif isinstance(elem, (bytes, bytearray)):
return self._add_as_param(elem.decode())
elif isinstance(elem, Compilable):
return elem.compile(self.replace(_is_root=False))
elif isinstance(elem, (int, float)):
Expand Down
12 changes: 4 additions & 8 deletions sqeleton/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,10 @@ def range(self, other: "ArithString", count: int):
checkpoints = split_space(self.int, other.int, count)
return [self.new(int=i) for i in checkpoints]

@property
@abstractmethod
def int(self):
...
# @property
# @abstractmethod
# def int(self):
# ...


class ArithUUID(UUID, ArithString):
Expand Down Expand Up @@ -224,10 +224,6 @@ def __init__(self, s: str, max_len=None):
self._str = s
self._max_len = max_len

# @property
# def int(self):
# return alphanumToNumber(self._str, alphanums)

def __str__(self):
s = self._str
if self._max_len:
Expand Down

0 comments on commit 29b8e32

Please sign in to comment.