An extension that registers all pharmacies in Argentina.
Project description
PymaciesArg
PymaciesArg is an extension that registers all pharmacies in Argentina.
Features
Requirements
Python 3.8+
Dependecies for this project.
- pandas==1.5.0 for build the backend.
- requests==2.28.1 for build the backend.
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()
-
run the following command line:
$> python -m scripts --date 2022-10-16 "BUENOS AIRES"
Recommended running instructions for dev:
-
Create a virtual environment:
$> python3 -m venv venv
-
Activate the newly created environment:
On macOS and Linux:
$> source venv/bin/activate
On Windows
c:\> .\env\Scripts\activate
-
Install dependencies:
$> (venv) python -m pip install -r requirements/dev.txt
-
Start the sample app on server locally:
$> (venv) pip install -e .
-
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
- Documentation
- Example Application using Postgresql
- Example Application using sqlite
- PyPI Releases
- Changelog
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file PymaciesArg-0.0.1.tar.gz
.
File metadata
- Download URL: PymaciesArg-0.0.1.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79e880e6f13f8e7866523b54fed8f101716fda70652ed8ecd755dfefc6735438 |
|
MD5 | 8b2cc26c6ad8f6d6356a21b495f9d728 |
|
BLAKE2b-256 | 3216418678e50e102af66e61b79c8075fbe26a75c5ad390682978dcdb8d479fc |
File details
Details for the file PymaciesArg-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: PymaciesArg-0.0.1-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8a8ee42c5864ad60a39fdc5b10bf30f59b3eebbdfb85c83b0d870f71417a94b |
|
MD5 | 719df2e648161b736af3e92c67cf0bd1 |
|
BLAKE2b-256 | 413ebf8febb99ef7a234327ccf5b7f3298912ac27dfefe5189b4ca37dbce9ac3 |