Skip to main content

Sqlite based dataset for torch.

Project description

Torchsqlite

Sqlite based dataset for torch.

1. Basic Usage

import pandas as pd
from torch.utils.data import DataLoader

from torchsqlite import SqliteDataset

df = pd.DataFrame()
df["time"] = [1,2]
df["data1"] = [2,4]
df["data2"] = [20,40]

table_name = "data"
query = f"SELECT data1, data2 FROM {table_name} ORDER BY time"

dataset = SqliteDataset(filename="train.db", table_name=table_name, query=query)
for row in dataset:
    print(row)

# [2, 20]
# [4, 40]

dataloader = DataLoader(dataset, batch_size=2)
for batch in dataloader:
    print(batch)
# [[2, 20], [4, 40]]

2. Rolling dataset(usually for time series)

import pandas as pd
from torch.utils.data import DataLoader

from torchsqlite import RollingSqliteDataset

df = pd.DataFrame()
df["time"] = [1,2]
df["data1"] = [2,4]
df["data2"] = [20,40]

table_name = "data"
query = f"SELECT data1, data2 FROM {table_name} ORDER BY time"

dataset = RollingSqliteDataset(filename="train.db", table_name=table_name, query=query, window=2)
for row in dataset:
    print(row)

dataloader = DataLoader(dataset, batch_size=2)
for batch in dataloader:
    print(batch)

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

torchsqlite-0.1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

torchsqlite-0.1.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file torchsqlite-0.1.1.tar.gz.

File metadata

  • Download URL: torchsqlite-0.1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.10.11 Windows/10

File hashes

Hashes for torchsqlite-0.1.1.tar.gz
Algorithm Hash digest
SHA256 8aeceba2c2ff8f12165dfbd9562b4d5a00e5233010bff3f0df84b0599274268c
MD5 fe8d453031f6c2ba17deb6df17226af6
BLAKE2b-256 4ae4f312e381520d393735aa5ce6417b1db208546585f03a95aa8e808df8798b

See more details on using hashes here.

File details

Details for the file torchsqlite-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: torchsqlite-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.22.3 CPython/3.10.11 Windows/10

File hashes

Hashes for torchsqlite-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 aa50718086a33bdd7b6d00efd2315e983c08045ce425a4a0040626614bfd7b89
MD5 1b8174ab0c718f52da362a0a5c5caeef
BLAKE2b-256 f3651061f67929ef7fdb087df871a6fcebea119e7ca31d0833d2368604a5554d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page