Skip to main content

DBRepo Python Library

Project description

DBRepo Python Library

Official client library for DBRepo, a database repository to support research based on requests, pydantic, tuspy and pika.

Installing

$ python -m pip install dbrepo

This package supports Python 3.11+.

Quickstart

Get public data from a table as pandas DataFrame:

from dbrepo.RestClient import RestClient

client = RestClient(endpoint="https://dbrepo1.ec.tuwien.ac.at")
# Get a small data slice of just three rows
df = client.get_table_data(database_id=7, table_id=13, page=0, size=3, df=True)
print(df)
#     x_coord         component   unit  ... value stationid meantype
# 0  16.52617  Feinstaub (PM10)  µg/m³  ...  21.0   01:0001      HMW
# 1  16.52617  Feinstaub (PM10)  µg/m³  ...  23.0   01:0001      HMW
# 2  16.52617  Feinstaub (PM10)  µg/m³  ...  26.0   01:0001      HMW
#
# [3 rows x 12 columns]

Import data into a table:

import pandas as pd
from dbrepo.RestClient import RestClient

client = RestClient(endpoint="https://dbrepo1.ec.tuwien.ac.at", username="foo",
                    password="bar")
df = pd.DataFrame(data={'x_coord': 16.52617, 'component': 'Feinstaub (PM10)',
                        'unit': 'µg/m³', ...})
client.import_table_data(database_id=7, table_id=13, file_name_or_data_frame=df)

Supported Features & Best-Practices

  • Manage user account (docs)
  • Manage databases (docs)
  • Manage database access & visibility (docs)
  • Import dataset (docs)
  • Create persistent identifiers (docs)
  • Execute queries (docs)
  • Get data from tables/views/subsets

Configure

All credentials can optionally be set/overridden with environment variables. This is especially useful when sharing Jupyter Notebooks by creating an invisible .env file and loading it:

REST_API_ENDPOINT="https://dbrepo1.ec.tuwien.ac.at"
REST_API_USERNAME="foo"
REST_API_PASSWORD="bar"
REST_API_SECURE="True"
AMQP_API_HOST="https://dbrepo1.ec.tuwien.ac.at"
AMQP_API_PORT="5672"
AMQP_API_USERNAME="foo"
AMQP_API_PASSWORD="bar"
AMQP_API_VIRTUAL_HOST="dbrepo"
REST_UPLOAD_ENDPOINT="https://dbrepo1.ec.tuwien.ac.at/api/upload/files"

You can disable logging by setting the log level to e.g. INFO:

from dbrepo.RestClient import RestClient
import logging
logging.getLogger().setLevel(logging.INFO)
...
client = RestClient(...)

Roadmap

  • Searching

Contact

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

dbrepo-1.5.1.tar.gz (39.2 kB view details)

Uploaded Source

Built Distribution

dbrepo-1.5.1-py3-none-any.whl (30.0 kB view details)

Uploaded Python 3

File details

Details for the file dbrepo-1.5.1.tar.gz.

File metadata

  • Download URL: dbrepo-1.5.1.tar.gz
  • Upload date:
  • Size: 39.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for dbrepo-1.5.1.tar.gz
Algorithm Hash digest
SHA256 1a52772dedf756bf48c52eec4df0c3a0c1fcef8034f47aa33c7ae5207cf85609
MD5 c6c3133ec30d3cf900dc13cd1444836d
BLAKE2b-256 eefbef4f6cb5d2004c19cc028ae1dac116e4fb7cdc7c48b94e8ecbb6dd794b6c

See more details on using hashes here.

File details

Details for the file dbrepo-1.5.1-py3-none-any.whl.

File metadata

  • Download URL: dbrepo-1.5.1-py3-none-any.whl
  • Upload date:
  • Size: 30.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for dbrepo-1.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a18d7304b3ea3d5ba9c0b94988911ed6a129d59f2116d362ae9e4bf5a2803e2e
MD5 770b0ba5c708cf604b0c3bb7ce1f7ab4
BLAKE2b-256 40cf41d2aeef5d224cda25d424c1332f9a73eb880b8c21e0180136fc67d051d7

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