Code Monkey home page Code Monkey logo

assignment's Introduction

Job interview assignment

Build Status StyleCI Scrutinizer Code Quality

The following describes how to run and use the solution for interview assignment.

Getting started

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

How it works

  1. A query is read from the cmd line and executed on the database.
  2. Before the query is executed its is checked for bad sql etc. "delete from users" and we are querying the correct table.
  3. Query is read to memory and then checked for the availability of the "id" column (which will be needed for deletion later on).
  4. 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.

Discussion

  1. Min. fields must be defined, I only check for "Id" because it is used for deletion.
  2. Before deleting from database, exported csv file should be loaded and verified against the select query.

Notes

  • This has been tested on my mac, other platforms with php7 and sqlite3 should work fine.

assignment's People

Contributors

cjonstrup avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.