The following describes how to run and use the solution for interview assignment.
Before cloning the repository make sure the following dependencies are installed.
- PHP 7
- php-sqlite3
- sqlite3
- composer
Clone this repository
git clone https://github.com/cjonstrup/assignment.git
Install the project dependencies via composer
composer install
Run the unit tests to verify the system is working
./vendor/bin/phpunit
Run the app and the test command for yourself
php app users 'select * from users limit 10' users.csv
- A query is read from the cmd line and executed on the database.
- Before the query is executed its is checked for bad sql etc. "delete from users" and we are querying the correct table.
- Query is read to memory and then checked for the availability of the "id" column (which will be needed for deletion later on).
- Rows are written to file in CSV format (semi-colon separated) with first row as column names. File is <output.csv> If writing error should fail, a cleanup will be attempted and <output.csv> will be deleted.
- Min. fields must be defined, I only check for "Id" because it is used for deletion.
- Before deleting from database, exported csv file should be loaded and verified against the select query.
- This has been tested on my mac, other platforms with php7 and sqlite3 should work fine.