copied from pysqlin google code project