Mira is a Ruby on Rails application which gives you a simple HTTP API for CSV files.
-
You create a Mira project. A project is simply a home for one or more CSV files, along with a datapackage.json file. More on that now...
-
You provide Mira with information about your CSV files by uploading a datapackage.json file to the project. This file provides metadata for the CSV files you plan to upload to the project. i.e. file names, columns names and types, delimiters etc. See here and here for more information about datapackage.json files and tabular data packages.
-
With the datapackage.json file Mira then does the following:
- it creates an empty database table for each CSV file specified in the datapackage.json file.
- it creates an API to these database tables which you can use to read and write data.
-
You write data to the database tables by uploading CSV files, or by using a JSON API.
-
You can query the data using simple API requests. Consider a table
mytable
in a project, with columnscol1
,col2
andcol3
. To get rows wherecol1
equals "XXX",col2
equals "YYY" andcol3
equals "ZZZ", you could make the followingGET
request:
http://localhost:3000/api/projects/1/tables/mytable/data?col1_eq=XXX&col2_eq=YYY&col3_eq=ZZZ
See the demo for more details on how the data can be queried.
- You can generate API keys to control the reading and writing data.
-
You're familiar with Ruby and Ruby on Rails.
-
PostgreSQL is installed
[https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-ruby-on-rails-application-on-ubuntu-14-04] (https://www.digitalocean.com/community/tutorials/how-to-use-postgresql-with-your-ruby-on-rails-application-on-ubuntu-14-04)
-
Clone the repository
-
Run bundle
bundle install
-
Update the config/database.yml file with your database credentials. Assuming you've created a user "mira" with full access to a database of the same name:
default: &default adapter: postgresql encoding: unicode pool: 5 host: localhost port: 5432 username: mira password: **your_password_here** development: <<: *default database: mira_dev test: <<: *default database: mira_test
-
Create and migrate database, and seed database with a single admin user (email = [email protected] and password = topsecret):
rake db:create rake db:migrate rake db:seed
-
Start your local development server
rails s
-
In a separate terminal start a background job to process uploaded files
rake jobs:work
-
Open up the Mira homepage:
[http://localhost:3000] (http://localhost:3000)
-
Download sample csv files + their datapackage.json file:
[mira_sample_data.tar.gz] (https://github.com/davbre/dummy-sdtm/blob/master/output/mira_sample_data/mira_sample_data.tar.gz) or [mira_sample_data.zip] (https://github.com/davbre/dummy-sdtm/blob/master/output/mira_sample_data/mira_sample_data.zip)
-
Log in, create a new project, first upload the datapackage.json file, then the sample csv files
-
Navigate to the following address for the project's API details:
Assuming a write API key has been generated, here's how you can write data:
curl -d "data[col1]=value1&data[col2]=val2" -H "X-Api-Key: 6041fa394bc84abe46ffdb71" http://localhost:3000/api/projects/1/tables/mytable/data