Skip to main content

Server implmentation of services for python

Project description

servc-lake

Requirements

As per usual, this package does not come bundled with any libraries to ensure full flexibility on dependencies and security vulnerabilities.

$ pip install servc servc-lake pyarrow [pandas]

Environment Variables

DATA_PATH - the location to start writing files. Default: /tmp/datalake

Parquet

import pyarrow as pa
from servclake.parquet import Parquet

table = Parquet(
  {
    "name": "mytesttable",
    "schema": pa.schema(
        [
            pa.field("col1", pa.string(), nullable=False),
            pa.field("col2", pa.uint32(), nullable=False),
            pa.field("j3", pa.uint32(), nullable=False),
        ]
    ),
    "partition": ["col2", "col1"],
  }
)

# write data to table
table.write(pa.Table.from_pylist([{"col1": "a", "col2": 1, "j3": 1}]))

# read partition. reads partiion 1 of col2.
df = table.read([1])

Delta Lake

import pyarrow as pa
from servclake.delta import Delta

# create a deltalake instance
deltalake = Delta(
  "/datalake",
  [
    {
      "name": "mytesttable",
      "schema": pa.schema([pa.field("col", pa.string()), pa.field("value", pa.int32())]),
      "partition": "col",
    }
  ]
)

# delcare our dataframe
df = pa.Table.from_pylist(
    [
        {"col": "df1", "value": 1},
        {"col": "asd2", "value": 2},
        {"col": "asd3", "value": 3},
        {"col": "asd4", "value": 4},
        {"col": "asd5", "value": 5},
    ],
    schema=pa.schema([pa.field("col", pa.string()), pa.field("value", pa.int32())]),
)

# write dataframe to lake
table = self.lake.write("mytesttable", df, mode="append")
print(table.to_pandas())

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

servc-lake-1.2.1.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

servc_lake-1.2.1-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file servc-lake-1.2.1.tar.gz.

File metadata

  • Download URL: servc-lake-1.2.1.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for servc-lake-1.2.1.tar.gz
Algorithm Hash digest
SHA256 0ca72c6745f3ea102832b93d9c3e8adbf4ea1fefc8e31590eb732b0960688cd4
MD5 4e8dde1f80a3f384456aebd5804519f0
BLAKE2b-256 87ffaf439d7d473264e5c14a18666ce012ccdb127c6249178b7edae31ac56020

See more details on using hashes here.

File details

Details for the file servc_lake-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: servc_lake-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for servc_lake-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b8f249ceed8316a6569966c68826b03e6616a491ca107092bc13eb888e89c5f
MD5 797f427188f93879818da026526d8e4e
BLAKE2b-256 b951ae2f386abffb2822787ba9420316bacec3689727ff5099f3abd519ae2751

See more details on using hashes here.

Supported by

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