mercredi 17 avril 2019

Unit testing SQL scripts from python

I have some SQL scripts from my colleagues for creating and inserting different tables in database. I'm using python and psycopg2 for execute this scripts on the server. Some of these tables are linked one to another (data is mapping from one table to another into different format) and I use apache-airflow for organize my python tasks that execute this SQL scripts. Also I'm using apache-airflow scheduling for automatic update this data some times per day.

Sometimes I get an error in SQL scripts like syntax error in table name or field. I'm currently catching this error on running of my apache-airflow DAG. I want to write some python unit tests for catching this errors before running DAG.

Should I replicate my database to test sandbox, execute this scripts in unit tests (also I should run my tests in certain sequence) or there are more convenient methods for testing this SQL scripts?

Aucun commentaire:

Enregistrer un commentaire