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
mytablein a project, with columns
col3. To get rows where
col2equals "YYY" and
col3equals "ZZZ", you could make the following
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.
PostgreSQL is installed
Clone the repository
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@example.com and password = topsecret):
rake db:create rake db:migrate rake db:seed
Start your local development server
In a separate terminal start a background job to process uploaded files
Open up the Mira homepage:
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