DataStore Factory Methods

### `from_hdfs`[​](#from-hdfs "Direct link to from-hdfs")

Create DataStore from HDFS.

```
DataStore.from_hdfs(url, **kwargs)
```

**Examples:**

```
ds = DataStore.from_hdfs("hdfs://namenode:8020/path/data.parquet")
```

### `from_url`[​](#from-url "Direct link to from-url")

Create DataStore from HTTP/HTTPS URL.

```
DataStore.from_url(url, format=None, **kwargs)
```

**Examples:**

```
ds = DataStore.from_url("https://example.com/data.csv")
ds = DataStore.from_url("https://raw.githubusercontent.com/user/repo/main/data.parquet")
```

---

## Databases[​](#databases "Direct link to Databases")

### `from_mysql`[​](#from-mysql "Direct link to from-mysql")

Create DataStore from MySQL database.

```
DataStore.from_mysql(host, database, table, user, password, port=3306, **kwargs)
```

**Parameters:**

|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Parameter Type Default Description|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `host` str *required* MySQL host|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `database` str *required* Database name|  |  |  |  |  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `table` str *required* Table name|  |  |  |  |  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | | `user` str *required* Username|  |  |  |  |  |  |  |  | | --- | --- | --- | --- | --- | --- | --- | --- | | `password` str *required* Password|  |  |  |  | | --- | --- | --- | --- | | `port` int `3306` Port number | | | | | | | | | | | | | | | | | | | | | | | | | | | |

**Examples:**

```
ds = DataStore.from_mysql(
    host="localhost",
    database="mydb",
    table="users",
    user="root",
    password="password"
)

# Using URI
ds = DataStore.uri("mysql://root:password@localhost:3306/mydb/users")
```

### `from_postgresql`[​](#from-postgresql "Direct link to from-postgresql")

Create DataStore from PostgreSQL database.

```
DataStore.from_postgresql(host, database, table, user, password, port=5432, **kwargs)
```

**Examples:**

```
ds = DataStore.from_postgresql(
    host="localhost",
    database="mydb",
    table="users",
    user="postgres",
    password="password"
)

# Using URI
ds = DataStore.uri("postgresql://postgres:password@localhost:5432/mydb/users")
```

### `from_clickhouse`[​](#from-clickhouse "Direct link to from-clickhouse")

Create DataStore from ClickHouse server.

```
DataStore.from_clickhouse(host, database, table, user=None, password=None, port=9000, **kwargs)
```

**Examples:**

```
ds = DataStore.from_clickhouse(
    host="localhost",
    database="default",
    table="hits",
    user="default",
    password=""
)

# Connection-level mode (explore databases)
ds = DataStore.from_clickhouse(
    host="analytics.company.com",
    user="analyst",
    password="secret"
)
ds.databases()                  # List databases
ds.tables("production")         # List tables
result = ds.sql("SELECT * FROM production.users LIMIT 10")
```

### `from_mongodb`[​](#from-mongodb "Direct link to from-mongodb")

Create DataStore from MongoDB.

```
DataStore.from_mongodb(uri, database, collection, **kwargs)
```

**Examples:**

```
ds = DataStore.from_mongodb(
    uri="mongodb://localhost:27017",
    database="mydb",
    collection="users"
)
```

### `from_sqlite`[​](#from-sqlite "Direct link to from-sqlite")

Create DataStore from SQLite database.

```
DataStore.from_sqlite(database_path, table, **kwargs)
```

**Examples:**

```
ds = DataStore.from_sqlite("data.db", table="users")

# Using URI
ds = DataStore.uri("sqlite:///data.db?table=users")
```

---

## Data Lakes[​](#data-lakes "Direct link to Data Lakes")

### `from_iceberg`[​](#from-iceberg "Direct link to from-iceberg")

Create DataStore from Apache Iceberg table.

```
DataStore.from_iceberg(path, **kwargs)
```

**Examples:**

```
ds = DataStore.from_iceberg("/path/to/iceberg_table")
ds = DataStore.uri("iceberg://catalog/namespace/table")
```

### `from_delta`[​](#from-delta "Direct link to from-delta")

Create DataStore from Delta Lake table.

```
DataStore.from_delta(path, **kwargs)
```

**Examples:**

```
ds = DataStore.from_delta("/path/to/delta_table")
ds = DataStore.uri("deltalake:///path/to/delta_table")
```

### `from_hudi`[​](#from-hudi "Direct link to from-hudi")

Create DataStore from Apache Hudi table.

```
DataStore.from_hudi(path, **kwargs)
```

**Examples:**

```
ds = DataStore.from_hudi("/path/to/hudi_table")
ds = DataStore.uri("hudi:///path/to/hudi_table")
```

---

## In-Memory Sources[​](#in-memory "Direct link to In-Memory Sources")

### `from_df` / `from_dataframe`[​](#from-df "Direct link to from-df")

Create DataStore from pandas DataFrame.

```
DataStore.from_df(df, name=None)
DataStore.from_dataframe(df, name=None)  # alias
```

**Examples:**

```
import pandas
from chdb.datastore import DataStore

pdf = pandas.DataFrame({'a': [1, 2, 3], 'b': ['x', 'y', 'z']})
ds = DataStore.from_df(pdf)
```

### `DataFrame` Constructor[​](#dataframe-constructor "Direct link to dataframe-constructor")

Create DataStore using pandas-like constructor.

```
from chdb import datastore as pd

# From dictionary
ds = pd.DataFrame({
    'name': ['Alice', 'Bob'],
    'age': [25, 30]
})

# From pandas DataFrame
import pandas
pdf = pandas.DataFrame({'a': [1, 2, 3]})
ds = pd.DataFrame(pdf)
```

---

## Special Sources[​](#special-sources "Direct link to Special Sources")

### `from_numbers`[​](#from-numbers "Direct link to from-numbers")

Create DataStore with sequential numbers (useful for testing).

```
DataStore.from_numbers(count, **kwargs)
```

**Examples:**

```
ds = DataStore.from_numbers(1000000)  # 1M rows with 'number' column
result = ds.filter(ds['number'] % 2 == 0).head(10)  # Even numbers
```

### `from_random`[​](#from-random "Direct link to from-random")

Create DataStore with random data.

```
DataStore.from_random(rows, columns, **kwargs)
```

**Examples:**

```
ds = DataStore.from_random(rows=1000, columns=5)
```

### `run_sql`[​](#run-sql "Direct link to run-sql")

Create DataStore from raw SQL query.

```
DataStore.run_sql(query)
```

**Examples:**

```
ds = DataStore.run_sql("""
    SELECT number, number * 2 as doubled
    FROM numbers(100)
    WHERE number % 10 = 0
""")
```

---

## Summary Table[​](#summary "Direct link to Summary Table")