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.
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)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| PymaciesArg-0.0.1.tar.gz | 9.5 kB | Without provenance | Details for PymaciesArg-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| PymaciesArg-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for PymaciesArg-0.0.1-py3-none-any.whl |
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
|
Security for PymaciesArg 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.