Skip to main content

SQLAlchemy query helper

Usage

class User(Base):
    id = Column(Integer, primary_key=True)
    name = Column(String)
    fullname = Column(String)
    nickname = Column(String)
    timestamp = Column(DateTime)
    addresses = relationship("Address")

class Address(Base):
    id = Column(Integer, primary_key=True)
    title = Column(String)
    description = Column(String)
    user_id = Column(Integer, ForeignKey("user.id"))

from sqlalchemy_query_helper.query_generator import generate_query

# it will return sql alchemy query object
query=generate_query(session,User,{
    "name":{"op":"eq","value":"john"},
    "addresses":{"title":{"op":"neq":"value":"new york city"}}
})
# this query is equivalent to below
"""
SELECT user.*,address.* from user
join address on address.user_id=user.id
where user.name='john' and address.title!='new york city'
"""
# notice that it will load joined table if it is in the query.
# There is no select option yet

Available operations

  • eq (equals)
  • neq (not equals)
  • gt (greater than)
  • gte (greater than equals)
  • lt (less than)
  • lte (less than equals)

More

  • Accepts date times as iso format and will convert to python datetime automatically.

Development

  • Install pipenv

  • make install

  • Make your changes and open PR

Test

  • Install sqllite3

  • make test

Release files for sqlalchemy-query-helper 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sqlalchemy-query-helper 0.0.5
File Size Uploaded
sqlalchemy-query-helper-0.0.5.tar.gz 3.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sqlalchemy-query-helper 0.0.5
File Interpreter ABI Platform
sqlalchemy_query_helper-0.0.5-py3-none-any.whl Python 3 none any Details

Total release size: 7.8 kB

Release files / sqlalchemy-query-helper-0.0.5.tar.gz

Download URL sqlalchemy-query-helper-0.0.5.tar.gz
Size 3.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f700bc3f9e99b9996363b5a64d4c45b2973fed3a64499f08d63371a562cc8a94
BLAKE2b-256 checksum
How to use checksums
e55127607e0d3d28a3c11a0d9d0d96eff9fa35db7dd9d67db14d8b170f5943e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release files / sqlalchemy_query_helper-0.0.5-py3-none-any.whl

Download URL sqlalchemy_query_helper-0.0.5-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
315fe85e6251804734dcc08073b22a91e90c94906c84e1d8e41ff9c4cc3de47b
BLAKE2b-256 checksum
How to use checksums
984567fce8b00b6cf3489166762356e710b69673fb56c0d47e619549f7124a32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.0.5 This release

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page