Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 27 lines (20 sloc) 553 Bytes
#!/usr/bin/python
import sys, os, string
import sqlite
import sarahlib
sys.stdout = os.fdopen(1, 'w', 0)
con, cur = sarahlib.opendb()
query = string.join(sys.argv[1:], ' ')
if not query:
print >>sys.stderr, 'syntax: sarahsql \'sql statement\''
print >>sys.stderr, 'error: You did not provide a SQL command as argument.'
sys.exit(1)
try:
cur.execute(query)
except sqlite.DatabaseError, m:
print >>sys.stderr, 'error: Syntax error in SQL statement, %s' % m
sys.exit(2)
for rec in cur.fetchall():
for col in rec:
print '%s\t' % col,
print
Something went wrong with that request. Please try again.