diff options
author | Marko Kreen | 2009-02-13 10:03:53 +0000 |
---|---|---|
committer | Marko Kreen | 2009-02-13 12:21:01 +0000 |
commit | 5521e5fc2f399a923fa7fb313bbe797cfa0d5baa (patch) | |
tree | 7df01ec195273b812bc9b64953a71ad1155d9438 /python/skytools/parsing.py | |
parent | 012aee6a0369d8a4b2617046a27659c02b0bb478 (diff) |
python/skytools update
- docstrings
- some preliminary python 3.0 compat (var names, print())
- sync with 2.1-stable
adminscript:
- move exec_cmd function to dbscript
dbstruct:
- support sequnces. SERIAL columns are not automatically created,
but the link beteween column and sequence is.
psycopgwrapper:
- drop support for psycopg1
- beginnings of quick DB-API / DictRow description.
quoting:
- new unquote_fqident() function, reverse of quote_fqident()
- quote_statement() accepts both row and dict
dbscript:
- catch startup errors
- use log.exception for exceptions, will result in nicer logs
sqltools:
- exists_sequence()
_pyquoting:
- fix typo in variable name
Diffstat (limited to 'python/skytools/parsing.py')
-rw-r--r-- | python/skytools/parsing.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/python/skytools/parsing.py b/python/skytools/parsing.py index 3aa94991..36b17d53 100644 --- a/python/skytools/parsing.py +++ b/python/skytools/parsing.py @@ -42,11 +42,14 @@ def parse_pgarray(array): # class _logtriga_parser: + """Parses logtriga/sqltriga partial SQL to values.""" def tokenizer(self, sql): + """Token generator.""" for typ, tok in sql_tokenizer(sql, ignore_whitespace = True): yield tok def parse_insert(self, tk, fields, values): + """Handler for inserts.""" # (col1, col2) values ('data', null) if tk.next() != "(": raise Exception("syntax error") @@ -73,6 +76,7 @@ class _logtriga_parser: raise Exception("expected EOF, got " + repr(t)) def parse_update(self, tk, fields, values): + """Handler for updates.""" # col1 = 'data1', col2 = null where pk1 = 'pk1' and pk2 = 'pk2' while 1: fields.append(tk.next()) @@ -97,6 +101,7 @@ class _logtriga_parser: raise Exception("syntax error, expected AND got "+repr(t)) def parse_delete(self, tk, fields, values): + """Handler for deletes.""" # pk1 = 'pk1' and pk2 = 'pk2' while 1: fields.append(tk.next()) @@ -108,6 +113,7 @@ class _logtriga_parser: raise Exception("syntax error, expected AND, got "+repr(t)) def parse_sql(self, op, sql): + """Main entry point.""" tk = self.tokenizer(sql) fields = [] values = [] |