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.1.0.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file servc-lake-1.1.0.tar.gz
.
File metadata
- Download URL: servc-lake-1.1.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c66363ecaf1cbd8b42a573b634b0db1412af30d7382694cb58a21c0cd9183ded |
|
MD5 | 70fa6f44664dd9d531fcdcf3db45b621 |
|
BLAKE2b-256 | e8cc9c56e12d344e1113447c7003530c8dfacf3ec9c0e3961f4ef4ca9d7dca94 |
File details
Details for the file servc_lake-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: servc_lake-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.8 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 | 9935bfad82d297019ad3a4c55a4093c2ec9a123d910bb6406e1e86a7bffa5401 |
|
MD5 | 8039cfcb316a3ccf4aca95a67c8fb697 |
|
BLAKE2b-256 | d1193d168183c34d0a476ee8136ce72d9db1c2d71cad0ed6f16da88ed3321cb8 |