sandman makes things REST

Imagine you have an existing database and want to be able to modify it with a tool through a nifty REST API, while still being able to edit it manually without hassle.

I guess we need to create a web backend and frontend, write models for our data and view functions to allow a mapping of their attributes to URLs to access and change them with http requests.. so much work!

Not with sandman:

$ pip install sandman
$ sandmanctl <database-uri>

for example:

$ sandmanctl mysql://username:password@host/database --host localsandman --port 8080

It will analyze your database, derive models from it, create REST API functions for them, map those to URLs that make sense and run a small server exposing everything on your chosen port, e.g. http://localsandman:8080/.

It will also create an admin page as the web GUI to your database on http://localsandman:8080/admin/.

How cool is that ?

All powered by flask and SQLAlchemy.

Note: It seems sandman is not maintained anymore, but a successor is in the making: sandman2, however I could not get it to run on my machine yet.

I also had two issues installing sandman on Windows 7 with Python 2.7, so I will quickly list the fixes here:

  • Installing via pip seems a bit broken. The resulting sandmanctl script failed to launch the server for me. Instead I installed from source (preferrably into a virtualenv) like:
    $ git clone
    $ python install
  • When trying to connect to a mysql database, the underlying SQLAlchemy defaults to the MySQLdb (available on pypi as MySQL-python) module, which on Windows can be a pain to install since it needs a compiler, which usually is not available. You can tell it to use a pure-python alternative named pymysql by modifying the URI like:
    $ pip install pymysql
    $ sandmanctl mysql+pymysql://username:password@host/database --host localsandman --port 8080

1 Comment

  1. set as following:
    pip install sandman2
    pip install pymysql
    sandman2ctl –port 8080 mysql+pymysql://root:root@localhost/us_states

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.