TolaData to CSV (for IATI) The main script "export_to_csv.py" can export data of an organisation from TolaData to a CSV File that can report against required IATI fields. This file can then be used to publish on IATI using a platform like Aidstream to generate an IATI XML File needed for publishing.
In this version, the database connection is made to a localhost.
You need to install Postgres:
sudo apt-get install postgresql postgresql-contrib
service postgresql start
To connect to postgres:
sudo -u postgres psql
You are now connected to the Database Management System. You need to create your database and give all the access to the user you want:
CREATE DATABASE demo;
ALTER ROLE postgres WITH PASSWORD 'postgres';
GRANT ALL PRIVILEGES ON DATABASE demo TO postgres;
Now you need to go back to your session to dump the data:
pg_restore -c -U postgres -d demo -v SQL_Dump.tar -W
If you are getting an error, try to restart the postgres service : /etc/init.d/postgresql restart
To execute the file you need to have python3 installed. Then you just need to execute the main file and put an organisation name as parameter, example:
python3 export_to_csv TolaData
You can filter the workflowlevel1 of the particular organisation by adding the condition to all the SQL queries. Example : " where c.name={} and b.name='Humanitarian Response to the Syrian Crisis' "
For production use, the main script needs to be pointed to a production database.
In a future version, the IATI Identifier also needs to be entered as a parameter. A functionnality can be added where the user will specify one or many WFL1 to get all the WFL2 activities.