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.0.tar.gz
(5.6 kB
view details)
Built Distribution
File details
Details for the file servc-lake-1.2.0.tar.gz
.
File metadata
- Download URL: servc-lake-1.2.0.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b860374a2934d0f08f3b3ebd8fe1ca6207d7a59e02b808e28f3c8a5c6021c563 |
|
MD5 | 336661e2acc76431a5307912cb761cd3 |
|
BLAKE2b-256 | ad4f2212568719a851eb2ea1d361d37a6140caf2e69dd102c6796aa4dd494f57 |
File details
Details for the file servc_lake-1.2.0-py3-none-any.whl
.
File metadata
- Download URL: servc_lake-1.2.0-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | e716d000753f3a91cad0c1eed79da13cc68561088537dd08513df39a95a92ce9 |
|
MD5 | 5e6916154c1c43eda864ff60961772ec |
|
BLAKE2b-256 | eaf5566f11d4120ac8273a95b9e8ce884ca4434f2e59801e57129b8b44742947 |