Skip to main content

samla

Fetches and parses MSSQL schema metadata (tables, views, columns) into structured Python objects.

Install

pip install samla

Usage

From a database connection

Connects directly to MSSQL and fetches schema metadata:

import pyodbc
from samla import get_and_parse_tables, FilterGroup

filters = [
    FilterGroup(catalog_patterns=["NorthernVault"], schema_patterns=["Reporting"]),
]

conn = pyodbc.connect("<your connection string>")
tables = get_and_parse_tables(conn=conn, source_system="ACME", filters=filters)

The SQL query used to fetch metadata from INFORMATION_SCHEMA is available here.

From a CSV file

If you cannot connect to the database directly, load from a pre-exported CSV file instead:

from pathlib import Path
from samla import load_tables_from_file

tables = load_tables_from_file(path=Path("tables.csv"))

To produce the CSV, save the output from a database run:

from samla import save_tables_to_file

save_tables_to_file(tables=tables, path=Path("tables.csv"))

Or from the command line

python main.py                        # fetch from database
python main.py --file tables.csv      # load from CSV file

Filtering

FilterGroup filters tables by catalog, schema, and/or table name using regex patterns. Multiple patterns within a field are OR'd; multiple FilterGroups are also OR'd between each other.

filters = [
    FilterGroup(schema_patterns=["Sales", "Person"]),
    FilterGroup(catalog_patterns=["AdventureWorks"], table_patterns=["^Product"]),
]

Data model

Table

Field Type Description
source_system str Identifier for the source system
server_name str | None Hostname of the server
catalog str Database catalog name
schema str Schema name
table str Table or view name
table_type TableType TABLE or VIEW
columns list[SourceColumn] Column definitions

SourceColumn

Field Type Description
column str Column name
data_type str SQL data type
length str | None Character max length
nullable bool Whether the column is nullable
scale int | None Numeric scale
precision int | None Numeric precision
is_primary_key bool Whether the column is a primary key
source_type TableType TABLE or VIEW

Development

pip install -e ".[dev]"
pytest

Metadata

Release files for samla 0.1.3

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

Source distribution (sdist)

Source distribution for samla 0.1.3
File Size Uploaded Provenance Actions
samla-0.1.3.tar.gz 7.0 kB Without provenance Details for samla-0.1.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for samla 0.1.3
File Interpreter ABI Platform Actions
samla-0.1.3-py3-none-any.whl Python 3 none any Details for samla-0.1.3-py3-none-any.whl

Total release size: 14.2 kB

Release files / samla-0.1.3.tar.gz

Download URL samla-0.1.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
0be3adfbe2b62cce87b1eb7fe285a596a5bc70b46093b340afcad4f9124830c6
BLAKE2b-256 checksum
How to use checksums
4c0ceaecd40127a09352fe83f658808af69a3ca9a706a9ae20081607b0eaf336
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / samla-0.1.3-py3-none-any.whl

Download URL samla-0.1.3-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11e30787ca10da23984fae70cbb8c988da3c0ee50dc2fa4dbd2bc8fa60598957
BLAKE2b-256 checksum
How to use checksums
789c2b496a4aa06773e3b146532dadfe0470bbdf9fbf660092b24635e570c20d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for samla 0.1.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files No provenance

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