diff options
author | Michele Simionato <michele.simionato@gmail.com> | 2011-06-13 09:57:28 +0200 |
---|---|---|
committer | Michele Simionato <michele.simionato@gmail.com> | 2011-06-13 09:57:28 +0200 |
commit | 68e5691ddde6246cd22c7cc6e0b189f2b343e661 (patch) | |
tree | afd0a525154b6540d048e039acea9db6da870e9a /plac/doc/sql_interface.py | |
parent | 2c9a92feab665152a02a7482bff9d31bafa2996e (diff) | |
download | micheles-68e5691ddde6246cd22c7cc6e0b189f2b343e661.tar.gz |
Removed the plac project, which now has its own page
Diffstat (limited to 'plac/doc/sql_interface.py')
-rw-r--r-- | plac/doc/sql_interface.py | 29 |
1 files changed, 0 insertions, 29 deletions
diff --git a/plac/doc/sql_interface.py b/plac/doc/sql_interface.py deleted file mode 100644 index 67c6233..0000000 --- a/plac/doc/sql_interface.py +++ /dev/null @@ -1,29 +0,0 @@ -import os, plac -from sqlalchemy.ext.sqlsoup import SqlSoup - -SQLKEYWORDS = set(['help', 'select', 'from', - 'inner', 'join', 'outer', 'left', 'right'] - ) # and many others -DBTABLES = set(['table1', 'table2']) # you can read them from the db schema - -COMPLETIONS = SQLKEYWORDS | DBTABLES - -class SqlInterface(object): - commands = ['SELECT'] - def __init__(self, dsn): - self.soup = SqlSoup(dsn) - def SELECT(self, argstring): - sql = 'SELECT ' + argstring - for row in self.soup.bind.execute(sql): - yield str(row) # the formatting can be much improved - -rl_input = plac.ReadlineInput( - COMPLETIONS, histfile=os.path.expanduser('~/.sql_interface.history'), - case_sensitive=False) - -def split_on_first_space(line, commentchar): - return line.strip().split(' ', 1) # ignoring comments - -if __name__ == '__main__': - plac.Interpreter.call(SqlInterface, split=split_on_first_space, - stdin=rl_input, prompt='sql> ') |