Metadata-Version: 2.1
Name: tipsql
Version: 0.0.13
Summary: Type Hint SQL Query Builder for Python.
Author: yassun7010
Author-email: yassun7010@outlook.com
Requires-Python: >=3.12,<4.0
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Provides-Extra: cli
Provides-Extra: postgresql
Provides-Extra: snowflake
Provides-Extra: sqlite3
Requires-Dist: inflection (>=0.5.1,<0.6.0) ; extra == "cli"
Requires-Dist: jinja2 (>=3.1.2,<4.0.0) ; extra == "cli"
Requires-Dist: tipsql-cli (==0.0.13) ; extra == "cli"
Requires-Dist: tipsql-core (==0.0.13)
Requires-Dist: tipsql-postgresql (==0.0.13) ; extra == "postgresql"
Requires-Dist: tipsql-snowflake (==0.0.13) ; extra == "snowflake"
Requires-Dist: tipsql-sqlite3 (==0.0.13) ; extra == "sqlite3"
Description-Content-Type: text/markdown

# Type Safed SQL Query Builder for Python

[![test](https://github.com/yassun7010/tipsql/actions/workflows/test-suite.yml/badge.svg)](https://github.com/yassun7010/tipsql/actions)
[![pypi package](https://badge.fury.io/py/tipsql.svg)](https://pypi.org/project/tipsql)

## Development Notes
### DDL

There are no plans for support.

DDL is often used infrequently as its syntax varies from database to database.
It is recommended that it be managed by a separate migration tool.

### For Table Relation

If a PrimaryKey or a join key is included as a constraint, it can be expressed as a NewType
to match the condition.

## Examples

```py
from textwrap import dedent

from tipsql.core.query.builder import QueryBuilder

from your_project.database.public import User, Address


builder = (
    query.chain()
    .from_(
        lambda c: c(User)
        .left_outer_join(
            Address,
        )
        .on(
            lambda c: c(User.id == Address.user_id)
            .and_(Address.city == "Tokyo")
        )
    )
    .select(
        User.id,
        User.name,
    )
)

assert (
    builder.build()
    == dedent(
        """
        SELECT
            users.id,
            users.name
        FROM
            users
            LEFT OUTER JOIN
                addresses
            ON
                users.id = addresses.user_id
                AND addresses.city = 'Tokyo';
        """
    ).strip()
)
```

