Socket
Socket
Sign inDemoInstall

tipsql

Package Overview
Dependencies
7
Maintainers
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    tipsql

Type Hint SQL Query Builder for Python.


Maintainers
1

Readme

Type Safed SQL Query Builder for Python

test pypi package

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

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()
)

FAQs


Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc