Skip to main content

DBRepo Python Library

Official client library for DBRepo, a database repository to support research based on requests, pydantic 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://test.dbrepo.tuwien.ac.at")
# Get a small data slice of just three rows
df = client.get_table_data(database_id="e0d82287-9099-4077-8f69-3c19fc3bc145",
                           table_id="71f8c746-ea26-4651-b3f2-ce46830f1af4",
                           page=0, size=3)
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]

Create table and import DataFrame into a table:

import pandas as pd
from dbrepo.RestClient import RestClient

client = RestClient(endpoint="https://test.dbrepo.tuwien.ac.at", username="foo",
                    password="bar")
df = pd.DataFrame(data={'x_coord': 16.52617, 'component': 'Feinstaub (PM10)',
                        'unit': 'µg/m³', ...})
df = df.set_index(['x_coord'])
client.create_table(database_id="e0d82287-9099-4077-8f69-3c19fc3bc145",
                    name="Sensor", is_public=True, is_schema_public=True,
                    dataframe=df)

... or just create the table schema by setting create_table(..., withData=False).

In both cases it is important to set the index to existing columns that uniquely identify a row. You can specify multiple columns:

...
df = df.set_index(['some_column', 'some_other_column'])

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"

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

Release files for dbrepo 1.13.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dbrepo 1.13.8
File Size Uploaded
dbrepo-1.13.8.tar.gz 103.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dbrepo 1.13.8
File Interpreter ABI Platform
dbrepo-1.13.8-py3-none-any.whl Python 3 none any Details

Total release size: 188.5 kB

Release files / dbrepo-1.13.8.tar.gz

Download URL dbrepo-1.13.8.tar.gz
Size 103.0 kB
Tags Source
SHA-256 checksum
How to use checksums
77f8a7f2cb0a969db38a4f13d52161cb0434ab9765aa700a7bbe61dcbd9b2c2b
BLAKE2b-256 checksum
How to use checksums
83ce0b18ae3d450747851e6eddb037e0d80c93427dce1727c9e168fc92cdc571
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / dbrepo-1.13.8-py3-none-any.whl

Download URL dbrepo-1.13.8-py3-none-any.whl
Size 85.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
311ca44c0512b6b5365b10655dbcac78c73d74c21228269072b712770c3c1b30
BLAKE2b-256 checksum
How to use checksums
4fa11b4ad86065bdd61e4322083dcab93c86fa6c7a1f0d0b811f54b31832a5e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

1.13.8 This release

2 release files

1.13.7

2 release files

1.13.6

2 release files

1.13.5

2 release files

1.13.3

2 release files

1.13.2

2 release files

1.13.0

2 release files

1.12.0

2 release files

1.11.0

2 release files

1.10.4

2 release files

1.10.3

2 release files

1.10.2

2 release files

1.10.1

2 release files

1.10.0

2 release files

1.9.3

2 release files

1.9.2

2 release files

1.9.1

2 release files

1.9.0

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page