Skip to main content

Inline SQL in any Python program, on local dataframes

Project description

Inline SQL

PyPI - Version PyPI - Python Version

An engine for inline SQL in any Python program.

import pandas as pd
from inline_sql import sql


def head_data(count: int) -> pd.DataFrame:
    return sql << "SELECT * FROM 'cars.csv' LIMIT $count"


cars = head_data(50)

origin_counts = sql << """
    SELECT origin, COUNT(*) FROM $cars
    GROUP BY origin
    ORDER BY count DESC
"""
print(origin_counts)

most_common = origin_counts.origin[0]
print(sql << """
    SELECT AVG(horsepower) FROM $cars
    WHERE origin = $most_common
""")

Operates directly on an in-memory database: access local variables (pandas frames), CSV files, and interpolate values into queries.

Table of Contents

Installation

pip install inline-sql

Contributions

Contributions are appreciated, especially in the following areas:

  • Additional query engines
  • File format support (CSV, Parquet, Arrow)
  • Support for dataframe libraries (e.g., Polars)
  • Distributed computing (Ray, Dask)
  • Documentation

License

inline-sql is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

inline_sql-0.0.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

inline_sql-0.0.2-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file inline_sql-0.0.2.tar.gz.

File metadata

  • Download URL: inline_sql-0.0.2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for inline_sql-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bd731a7532b84153cdb3de24016a1c730ee10683f7a0b1701e988d8c05019876
MD5 8824de2ddefb92f7bbd8edab16781e01
BLAKE2b-256 8a57f6bfc42d426a1474e59a0566505ccb3f422cf165ea25e6519f01a0072e72

See more details on using hashes here.

File details

Details for the file inline_sql-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for inline_sql-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3368e49bd8a30ec0378200ca6b9403c81cc4641fd785babd97152b269ae96f9a
MD5 c47b34db48e5f385fe6065726dc67a99
BLAKE2b-256 7c8ba195d98f4ed0a05fbc5842848837148bea00d83be8df61a0def34b7b117a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page