HTSQL

Presenter:Catherine Devlin
Date: March 26th, 2011
Location:Indiana LinuxFest 2011

About me

irc.freenode.net #htsql: Kirill Simonov

This talk does not represent official Dell positions. I don't think Dell even knows I'm giving it...

Relational Databases

dilbert.gif

Getting data back out

blackhole.gif

Seeing Data

HTSQL

URL -->
optimized SQL -->
RDBMS -->
formatted result

SELECT *

A real query

"How many programs and department does each school have?"

SELECT sch.name,
   (SELECT COUNT(1) FROM program
     WHERE school = sch.code),
   (SELECT COUNT(1) FROM department
     WHERE school = sch.code)
   FROM school AS sch
 ORDER BY sch.code ASC

... in HTSQL

/school{name, count(program), count(department)}

HTSQL is...

Written in Python

Virtues

Works With

Installing

http://htsql.org/doc/install.html

apt-get install python python-setuptools \
                python-yaml python-psycopg2 mercurial
hg clone http://bitbucket.org/prometheus/htsql
cd htsql
make build
make install

Running

htsql-ctl server pgsql://user:pass@host:port/database

Ten Tiny Tastes of HTSQL

#1 - Selecting Data

An example (E1):

/course{department+, no, credits-, title}

#2 - Linking Data

An example (E2):

/department{*, school.name}

#3 - Filtering Data

For example (E3):

/course?credits<3&department.school='ns'

#4 - Squiggly filters

/student?name~'y'

/department?school={'eng','ns'}

#5 - Aggregating Data

/course{title, credits, department.name}

/department{name, course.title, course.credits} (No!)

/department{name, sum(course.credits)}

/school{code, avg(department.count(course))}

#6 - Pluggable Formatters

For example (E6):

/course?credits<3&department.school='ns'/:txt

#7 - Table Expressions

An example (E7):

/department.sort(school).limit(10,5)

#8 - Clean it up

/school{code, avg(department.count(course))}

/school{code, avg(department.count(course)) :round 2 :as 'Average courses per department'}

#9 - Directly from Python

>>> from htsql import HTSQL
>>> from htsql.request import produce
>>> htsql = HTSQL('pgsql:htsql_regress')
>>> with htsql:
...     for row in produce('/school'):
...         print row
...

#10 - HTRAF Dashboarding

htraf.htsql.org

Development Status

HTSQL is quite usable currently, but it may have gaps for a given application. Particular items Prometheus is working on:

Credits

Written by Kirill Simonov and Clark Evans (Prometheus Research)

Generous support for HTSQL was provided by Prometheus Research, LLC and The Simons Foundation. This material is also based upon work supported by the National Science Foundation under Grant #0944460.

Dual-License & Support

htsql.com

More info