Skip to main content

Medical Procurement of Ukraine DataLakeHouse project.

Project description

Dbm

Project with usefull utilities for managing you DB.

Usage

Config

1. Config via dict

Create you config in dictionary:

config = {
    "dms": "mysql",
    "host": "host",
    "port": "port",
    "user": "<your user>",
    "password": "<your password>",
    "database": "<your_db_name>"
}

IMPORTANT : Make sure to use ENV variables for user and password:

Example

user = os.environ.get('MYSQL_PROD_USER')
password = os.environ.get('MYSQL_PROD_PWD')

2. class config

Alternatively - you can create it dirrectly in DBmanagerConfig class.

from dbmanager import DBmanagerConfig

conf = return DBmanagerConfig(
    'mysql',
    '<your database>',
    user,
    password,
    host='host',
    port='port')

DBmanager creation

from dmanager import make_db_manager
from sqlalchemy import MetaData

metadata = MetaData()

dbm = make_db_manager(config, metadata)

metadata - sqlalchemy class for storing all infor about tales. Even if you dont have it yet in your project - you must create it.

DBmanager usage example

import pandas as pd
from sqlalchemy import Integer, MetaData
from sqlalchemy.orm import DeclarativeBase, mapped_column, Mapped

from dbmanager import make_db_manager
from dbmanager.manager import DBmanager

METADATA = MetaData()

def make_dbm(dbms: str) -> DBmanager:
    config['dbms'] = dbms
    return make_db_manager(config, METADATA)

class Base(DeclarativeBase):
    metadata = METADATA


class FooTable(Base):
    __tablename__ = 'foo_bar_table'

    id: Mapped[int] = mapped_column(Integer, primapy_key=True)
    data: Mapped[str]



if __name__ == '__main__':
    dbm = make_dbm('mysql')
    dbm.create_table(FooTable)
    data = pd.read_csv('somecsv.csv')
    dbm.upsert(FooTable, data)

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

warehouser-0.3.9.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

warehouser-0.3.9-py3-none-any.whl (22.4 kB view details)

Uploaded Python 3

File details

Details for the file warehouser-0.3.9.tar.gz.

File metadata

  • Download URL: warehouser-0.3.9.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for warehouser-0.3.9.tar.gz
Algorithm Hash digest
SHA256 b58af5a45bdfd1e93e4c58a03e1a2c5090147b278524d0606b8a2756cf71ea39
MD5 ab466d70af92c5338e0058fdf8179a6e
BLAKE2b-256 b115fabb53de1df668d4987a1c0b1792495d57262407f42b6c970cbed38a4298

See more details on using hashes here.

File details

Details for the file warehouser-0.3.9-py3-none-any.whl.

File metadata

  • Download URL: warehouser-0.3.9-py3-none-any.whl
  • Upload date:
  • Size: 22.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.12

File hashes

Hashes for warehouser-0.3.9-py3-none-any.whl
Algorithm Hash digest
SHA256 8efc8d05d292db6233a7e78a2e03c5f6c9dca50cead517bb79d2e28c742dfe57
MD5 94e26aad9e010077e0bbfaa678ca8504
BLAKE2b-256 4e4a86d67cc87957bc3d7f9e587697448b703c2f3f789c28a516d4d3c8ba1a53

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page