Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .env-mysql.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
SERVER=localhost
PORT=3306
USERNAME=username
PASSWORD=password
DATABASE=db
CDM_SCHEMA=
VOCAB_FILE_DIR='.'
CREATE_TABLES=False
DELETE_TABLES=True
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.env
.env-mysql
vocab/*.csv
48 changes: 47 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# OMOP Vocabulary Loader

Currently supports PostgreSQL only.
# Postgres Database Section

This Python script is a modified version of the [LoadVocabFromCsv() from OHDSI/ETL-Synthea](https://github.com/OHDSI/ETL-Synthea/blob/main/R/LoadVocabFromCsv.r) written in R, licensed under the Apache License 2.0.

## What It Does
Expand Down Expand Up @@ -51,3 +52,48 @@ Download your vocabulary CSV files from the [Athena website](http://athena.ohdsi
## Error Handling

The script is equipped to handle both database-specific errors (using `psycopg2.Error`) and general exceptions. If an error occurs, a descriptive message will be printed to the console, providing details about the file and the nature of the error.

# Mysql Database

this is the mysql db version

## Requirements

Ensure you have Python 3.x installed. Then, install the necessary packages:

```{bash}
pip install -r requirements-mysql.txt
```

Download your vocabulary CSV files from the [Athena website](http://athena.ohdsi.org/vocabulary/list) and place them in a directory of your choice, e.g., `./vocab`. The script will read the files from this directory.

## Instructions

1. **Set Up Environment Variables**:
Create a `.env-mysql` file in the same directory as the script. This file should have the following structure:

```{bash}
SERVER=your_server
PORT=your_port
USERNAME=your_username
PASSWORD=your_password
DATABASE=your_database_name
VOCAB_FILE_DIR=path_to_your_csv_files
DELETE_TABLES=True|False (default True)
CREATE_TABLES=True|False (default False)
```

Replace the placeholders with your actual details.

2. **Run the Script**:
Navigate to the script's directory and execute:

```{bash}
python load_mysql.py
```

3. **Monitor the Output**:
The script provides status updates and error messages in the console. It will notify you of the start time, processed lines, remaining lines, and end time for each file.
## Error Handling

The script is equipped to handle both database-specific errors (using `pymysql.Error`) and general exceptions. If an error occurs, a descriptive message will be printed to the console, providing details about the file and the nature of the error.
Loading