Skip to main content

PyExtrica Library for Extrica Product

PyExtrica allows you to query and transform data in Extrica (Data To AI) platform directly without having to download the data locally. This library provides seamless access to the Extrica platform, allowing users to execute SQL queries and retrieve metadata such as catalog names, schema names, table names, and column information.

Getting Started

Installation

You can install PyExtrica via pip:

pip install pyextrica

Usage

To start using PyExtrica, you first need to import the PyExtricaFunctions module:

from pyextrica import PyExtricaFunctions

Connecting to Extrica

To connect to the Extrica platform, use the extrica_engine method:

from pyextrica import PyExtricaFunctions

# Define connection parameters
user_email = "your_email@example.com"
password = "your_password"
host = "host"
port = 1234 
catalog = "your_catalog"
platform = "data_sources"  # Platform should be either "data_products" or "data_sources"

# Establish connection to Extrica
engine = PyExtricaFunctions.extrica_engine(f"pyextrica://{user_email}:{password}@{host}:{port}/{catalog}?platform={platform}")

Using SQL

You can execute SQL queries using the execute_sql_query method:

sql_query = """
    SELECT column1, column2 FROM table_name LIMIT 10
"""

result = PyExtricaFunctions.execute_sql_query(engine, sql_query)

Replace sql_query with your desired SQL query string.

Querying Data

import pandas as pd

# Execute query and store result in DataFrame
df = pd.DataFrame(result, columns=['column1', 'column2'])
print(df.head())

# Perform DataFrame operations
# Example: Filter DataFrame
filtered_df = df[df['column1'] > 100]
print(filtered_df.head())

DataFrame Aggregation

# Example: Aggregating DataFrame
aggregated_df = df.groupby('column1').agg({'column2': 'sum'}).reset_index()
print(aggregated_df.head())

DataFrame Join

sql_query2 = """
    SELECT column3, column4 FROM second_table LIMIT 10
"""
result2 = PyExtricaFunctions.execute_sql_query(engine, sql_query2)
df2 = pd.DataFrame(result2, columns=['column3', 'column4'])

# Join DataFrames
joined_df = df.merge(df2, on='common_column')
print(joined_df.head())

Available Methods

PyExtrica provides the following methods for interacting with the Extrica platform:

  • extrica_engine: Connects to the Extrica platform.
  • execute_sql_query: Executes SQL queries.
  • get_catalog_names: Retrieves catalog names. (Requires platform=data_products for data products or platform=data_sources for data sources). For data products, catalog name represents the domain name, and schema name represents the subdomain name. For data sources, it is similar to Trino catalog and schema.
  • get_schema_names: Retrieves schema names. (Requires platform=data_products for data products or platform=data_sources for data sources)
  • get_table_names: Retrieves table names. (Requires platform=data_products for data products or platform=data_sources for data sources)
  • get_table_columns: Retrieves column information for a specified table. (Requires platform=data_products for data products or platform=data_sources for data sources)
# Retrieve catalog names
catalogs = PyExtricaFunctions.get_catalog_names(engine)
print("Catalogs:", catalogs)

# Retrieve schema names
schemas = PyExtricaFunctions.get_schema_names(engine)
print("Schemas:", schemas)

# Retrieve table names
tables = PyExtricaFunctions.get_table_names(engine, schema='schema_name')
print("Tables:", tables)

# Retrieve columns information for a table
columns_info = PyExtricaFunctions.get_table_columns(engine, schema='schema_name', table_name='table_name')
print("Columns Information:", columns_info)

Supported Operations

DML operations are only supported for Data Sources and not for Data Products, while DDL operations are supported by both Data Sources and Data Products in PyExtrica.

Example of DML Query

# Example of executing a DML query
dml_query = """
    INSERT INTO table_name (column1, column2) VALUES (value1, value2)
"""

result = PyExtricaFunctions.execute_sql_query(engine, dml_query)
print(result)  

Metadata

Release files for pyextrica 17.2.2

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

Source distribution (sdist)

Source distribution for pyextrica 17.2.2
File Size Uploaded
pyextrica-17.2.2.tar.gz 39.9 kB Details

Built distribution (wheel)

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

Total release size: 82.2 kB

Release files / pyextrica-17.2.2.tar.gz

Download URL pyextrica-17.2.2.tar.gz
Size 39.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9ef292485a699b80348279aceb194257574c6dc28abb1400d58ec71a613301f8
BLAKE2b-256 checksum
How to use checksums
78a70e3c43b3e4646a534ec7140aa436dcb86252d1cc59541768563ac0659096
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.7

Release files / pyextrica-17.2.2-py3-none-any.whl

Download URL pyextrica-17.2.2-py3-none-any.whl
Size 42.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8973e6cc5ee83649a135b520493e3b0c18247e033d5e53d924f0b08188b00acb
BLAKE2b-256 checksum
How to use checksums
67601b1dff52158818a1735077a7d8e06f10752018b965dc64e9bd9403a384c0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

17.2.2 This release

2 release files

17.2.1

2 release files

17.2.0

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