Skip to main content

No project description provided

Project description

Aluminum

A fast python ORM for InfluxDB 2 written in Rust.

Introduction

Aluminum is a fast Python library written in Rust that provides an ORM interface for interacting with InfluxDB.

Getting Started

This section will guide you through the basic steps of using the library. It will cover:

  • Setting up a connection with an engine
  • Creating a bucket
  • Retrieving a bucket
  • Adding data to a bucket
  • Querying data from a bucket

Installation

you can install Aluminum using pip:

pip install aluminum

To use the library, you first need to create an instance of an engine and bind it to the Store.

from aluminum import Engine, Store, Base

engine = create_engine(
        host="http://localhost:8086",
        token="<INFLUXDB-TOKEN>",
        org_id="<ORG-ID>",
    )

# Bind it to the store
store = Store(bind=engine)
# Initialize the Store's metadata for your models
store.collect(Base)

The Store

After setting up the store, you can create a bucket by calling the create_bucket method of the Store instance. The method takes a class that inherits from Base as an argument and returns a bucket instance.

from aluminum.base import Base

class SensorBucket(Base):
  tag: str
  measurement: str
  field: int

async def run_async_example():
  # Create a bucket
  bucket = await store.create_bucket(SensorBucket)
  
  # Get a bucket
  bucket = store.get_bucket(SensorBucket)
  
  # Get all buckets
  buckets = store.get_buckets()
  
  # Delete a bucket
  await store.delete_bucket(SensorBucket)

Adding Data to a Bucket

To add data to a bucket, you can call the add method of the bucket instance. The add method takes an instance of the bucket class as an argument.

from aluminum.base import Base

class SensorBucket(Base):
  tag: str
  measurement: str
  field: int

async def run_async_example():
  msmnt = SensorBucket(tag="My Tag", measurement="My Measurement", field=10)
  await bucket.add(user)

Querying Data from a Bucket

To query data from a bucket, you can call the execute method of the bucket instance. The execute method takes a Select instance as an argument and returns a list of bucket class instances that match the query.

from aluminum import select

async def run_async_example():
  stmt = select(SensorBucket).where(SensorBucket.tag == "My Tag", SensorBucket.field > 0)
  result = await bucket.execute(stmt) # list of SensorBucket

Acknowledgement

License

Licensed under the MIT License.

Copyright (c) 2022 Gabriele Frattini

Need Help?

If you have any questions or need help getting started, please reach out by opening an issue.

Conributions are welcome.

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

aluminum-0.1.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

aluminum-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (1.6 MB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

File details

Details for the file aluminum-0.1.0.tar.gz.

File metadata

  • Download URL: aluminum-0.1.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.14.12

File hashes

Hashes for aluminum-0.1.0.tar.gz
Algorithm Hash digest
SHA256 157157b58c4999d6a1419312edcee852e04b58377aab7814b5d294a0f4afe304
MD5 aae9ed6e8a85df7e7f6b38494642aa52
BLAKE2b-256 3393cfa1d9d67c4c5f4a2dd663e9006f868e8c6eb25e0ea1c6c6590c99c025b8

See more details on using hashes here.

File details

Details for the file aluminum-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for aluminum-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 984c2485533ddb161655384d9cd5408ddcc321f5bb6f78ff7c12d8d1a5060d03
MD5 e32927d8af4a3b5f551ad85fc7e23638
BLAKE2b-256 ae3b23925b1986584ff976f687414fd7c3d1efd5d3155f598ee9877f0cf78012

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