Skip to main content

No project description provided

Project description

TraceSQL Python Package

The tracesql Python package allows you to connect to the TraceSQL server and analyze SQL code for lineage. This package can generate lineage data and provide a downloadable SVG image of the lineage for visualization.

Features

  • Connects to TraceSQL API.
  • Analyzes SQL code to generate data lineage.
  • Outputs the lineage in JSON format.
  • Generates an SVG image of the lineage.

Installation

You can install the tracesql package via pip:

pip install tracesql

Usage

Simple example

from tracesql import analyze_lineage

code = """
CREATE TABLE active_customers AS
SELECT customer_id, first_name || ' ' || last_name as fullname, email
FROM customers
WHERE status = 'active';
"""
response = analyze_lineage(code)

# Save the SVG image of the lineage
with open("image.svg", "w") as fw:
    fw.write(response.svg)

# Save the lineage data in JSON format
with open("lineage.json", "w") as fw:
    fw.write(response.lineage.model_dump_json(indent=2))

print("Lineage successfully saved in files.")

Here is output for this example: simple

Parameters

  • query (str): The SQL query whose lineage you want to analyze.
  • db_model (DbModel): The database model containing the tables and columns used in the SQL query.

Response

  • svg: A string representing the SVG image of the lineage.
  • lineage: An object containing the lineage data in a pydantic class.

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

tracesql-0.1.6.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

tracesql-0.1.6-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file tracesql-0.1.6.tar.gz.

File metadata

  • Download URL: tracesql-0.1.6.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for tracesql-0.1.6.tar.gz
Algorithm Hash digest
SHA256 a277148bb74c596164bdf8527e763922fac02a09790ca7d9ccab2a91292e21e2
MD5 ad101ede6e6154b83d7bbfaa2570529a
BLAKE2b-256 d9419408fcbd757cf48c6a381a322cc6e1dd49ee512090575b345d843ec77d80

See more details on using hashes here.

File details

Details for the file tracesql-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: tracesql-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.15

File hashes

Hashes for tracesql-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f210829bcece8d5712a5e8ddad1dac7c3fa361dc7a3ba69701968bcf816637cb
MD5 7a9c09d29f5e1bd0fb576559d355508f
BLAKE2b-256 1b223ce1a2a6a3f59cd64f2c6244182c7f5d00ead4d2a9db6695f95ba99140d4

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