Skip to main content

PymaciesArg

Build status codecov Documentation Status docstr-cov GitHub license Forks star issues GitHub contributors black

PymaciesArg is an extension that registers all pharmacies in Argentina.

Features

Requirements

Python 3.8+

Dependecies for this project.

intallation

You can install via pip:

    $> pip install PymaciesArg

Example

Register the extension:

import os
import pathlib

import click

from pymacies_arg import (
    DepartmentsLoader,
    LocationsLoader,
    PharmaciesLoader,
    PymaciesArg,
    TABLE_NAMES,
)

from sqlalchemy import create_engine

# this path is pointing to project/
PATH = os.path.abspath(os.path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = "sqlite:///" + PATH + "/db_data.db"

engine = create_engine(SQLALCHEMY_DATABASE_URI)


# this path is pointing to project/sample_app_sqlite
CURRENT_PATH = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))

query1 = """CREATE TABLE IF NOT EXISTS pharmacies (
    "id"  INTEGER PRIMARY KEY,
    "name" VARCHAR(255) NOT NULL,
    "id_location"  INTEGER NOT NULL,
    "id_department"  INTEGER NOT NULL,
    "postal_code"  INTEGER NOT NULL,
    "adress" VARCHAR(255) NOT NULL);"""

query2 = """CREATE TABLE IF NOT EXISTS department (
    "id_department"  INTEGER NOT NULL PRIMARY KEY,
    "department" VARCHAR(255) NOT NULL,
    FOREIGN KEY (id_department) REFERENCES pharmacies(id_department));"""

query3 = """CREATE TABLE IF NOT EXISTS "locations"(
    "id_location"  INTEGER PRIMARY KEY,
    "location" VARCHAR(255) NOT NULL,
    FOREIGN KEY (id_location) REFERENCES pharmacies(id_location));"""


def create_table():
    with engine.connect() as conn:
        for tname in TABLE_NAMES[0:3]:
            print(f"create table {tname}")
            for q in [query1, query2, query3]:
                conn.execute(f"DROP TABLE IF EXISTS {tname};")
                conn.execute(q)


# : configure the command for run pipeline.
@click.command()
@click.option("--date", help="run date in format yyyy-mm-dd")
@click.argument("province")
def run_pipeline(date, province) -> None:

    pymacies = PymaciesArg(date, CURRENT_PATH)
    # Extract
    print("Extracting")
    file_paths = pymacies.extract_raws()

    # Transform
    print("Tansform")
    paths = pymacies.trasform_raws(file_paths, province)

    # Load
    print("Loading")
    PharmaciesLoader(engine).load_table(paths[0])
    LocationsLoader(engine).load_table(paths[1])
    DepartmentsLoader(engine).load_table(paths[2])

    # Done
    print("Done!")


if __name__ == "__main__":
    create_table()
    run_pipeline()
  1. run the following command line:

    $> python -m scripts --date 2022-10-16 "BUENOS AIRES"
    

Recommended running instructions for dev:

  1. Create a virtual environment:

    $> python3 -m venv venv
    
  2. Activate the newly created environment:

    On macOS and Linux:

    $> source venv/bin/activate
    

    On Windows

    c:\> .\env\Scripts\activate
    
  3. Install dependencies:

    $> (venv) python -m pip install -r requirements/dev.txt
    
  4. Start the sample app on server locally:

    $> (venv) pip install -e .
    
  5. Start the sample app on server locally:

    $> (venv) python application/pipeline.py
    10/16/2022 04:58:34 AM - pymacies_arg - INFO - Extracting
    10/16/2022 04:58:35 AM - pymacies_arg - INFO - Tansform
    10/16/2022 04:58:38 AM - pymacies_arg - INFO - Loading
    10/16/2022 04:58:40 AM - pymacies_arg - INFO - Done!
    

Links

Authors

  • Ferreira, Juan David

Please submit bug reports, suggestions for improvements and patches via the (E-mail: juandavid9a0@gmail.com).

Contributors

Credits goes to these peoples:

Official repository and Issues

License

PymaciesArg is free software you can redistribute it and/or modify it under the terms of the MIT License. For more information, you can see the LICENSE file for details.

Metadata

Release files for PymaciesArg 0.0.1

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

Source distribution (sdist)

Source distribution for PymaciesArg 0.0.1
File Size Uploaded
PymaciesArg-0.0.1.tar.gz 9.5 kB Details

Built distribution (wheel)

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

Total release size: 21.5 kB

Release files / PymaciesArg-0.0.1.tar.gz

Download URL PymaciesArg-0.0.1.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
79e880e6f13f8e7866523b54fed8f101716fda70652ed8ecd755dfefc6735438
BLAKE2b-256 checksum
How to use checksums
3216418678e50e102af66e61b79c8075fbe26a75c5ad390682978dcdb8d479fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release files / PymaciesArg-0.0.1-py3-none-any.whl

Download URL PymaciesArg-0.0.1-py3-none-any.whl
Size 11.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a8a8ee42c5864ad60a39fdc5b10bf30f59b3eebbdfb85c83b0d870f71417a94b
BLAKE2b-256 checksum
How to use checksums
413ebf8febb99ef7a234327ccf5b7f3298912ac27dfefe5189b4ca37dbce9ac3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.15

Release history Release notifications | RSS feed

This release

0.0.1 This release

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