Skip to content
PYGWALKER
API Reference
Dataset

PyGWalker Dataset Guide

This guide explains how to use PyGWalker with various data sources, including different DataFrame libraries and databases.

Working with DataFrames

PyGWalker supports multiple DataFrame libraries. Here's how to use them:

Pandas

import pygwalker as pyg
import pandas as pd
 
df = pd.read_csv("data.csv")
walker = pyg.walk(df)

Polars

import pygwalker as pyg
import polars as pl
 
df = pl.read_csv("data.csv")
walker = pyg.walk(df)

Modin

import pygwalker as pyg
import modin.pandas as mpd
 
df = mpd.read_csv("data.csv")
walker = pyg.walk(df)

Working with Databases

PyGWalker can connect to various databases using SQLAlchemy. Here's how to set it up:

Using the Connector

To connect to a database, use the Connector class:

from pygwalker.data_parsers.database_parser import Connector
 
conn = Connector(
    "snowflake://username:password@host/database/schema",
    """
        SELECT
            *
        FROM
            XXX
    """
)

Connector Parameters

ParameterTypeDefaultDescription
urlstr-Database URL (refer to SQLAlchemy documentation)
view_sqlstr-SQL query to select data
engine_paramsOptional[Dict[str, Any]]NoneAdditional engine parameters (refer to SQLAlchemy docs)

Database-Specific Examples

Snowflake

from pygwalker.data_parsers.database_parser import Connector
import pygwalker as pyg
 
conn = Connector(
    "snowflake://username:password@host/database/schema",
    "SELECT * FROM table_name"
)
 
walker = pyg.walk(conn)

PostgreSQL

from pygwalker.data_parsers.database_parser import Connector
import pygwalker as pyg
 
conn = Connector(
    "postgresql+psycopg2://username:password@host:port/database",
    "SELECT * FROM table_name"
)
 
walker = pyg.walk(conn)

Other Databases

PyGWalker supports all databases compatible with SQLAlchemy. To use a specific database:

  1. Refer to the SQLAlchemy documentation for the correct URL format.
  2. Install the appropriate database driver.
  3. Use the Connector class with the correct URL and SQL query.

For more information on supported databases and their configurations, consult the SQLAlchemy documentation.