diff options
| author | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-05 14:59:38 -0700 |
|---|---|---|
| committer | Victor Uriarte <victor.m.uriarte@intel.com> | 2016-06-06 07:55:39 -0700 |
| commit | b114ff6361550246cb5cb96168d25fe46bd355ef (patch) | |
| tree | b998ea09ac3317c0c2c2eec4b009eb601c920477 /examples | |
| parent | c43fccfefed0806cca52bea48d232ddf72f842cd (diff) | |
| download | sqlparse-b114ff6361550246cb5cb96168d25fe46bd355ef.tar.gz | |
Update init and misc files
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/column_defs_lowlevel.py | 13 | ||||
| -rw-r--r-- | examples/extract_table_names.py | 10 |
2 files changed, 18 insertions, 5 deletions
diff --git a/examples/column_defs_lowlevel.py b/examples/column_defs_lowlevel.py index e804bb2..7cce753 100644 --- a/examples/column_defs_lowlevel.py +++ b/examples/column_defs_lowlevel.py @@ -1,5 +1,11 @@ #!/usr/bin/env python - +# -*- coding: utf-8 -*- +# +# Copyright (C) 2016 Andi Albrecht, albrecht.andi@gmail.com +# +# This example is part of python-sqlparse and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php +# # Example for retrieving column definitions from a CREATE statement # using low-level functions. @@ -21,17 +27,16 @@ par = parsed.token_next_by(i=sqlparse.sql.Parenthesis) def extract_definitions(token_list): # assumes that token_list is a parenthesis definitions = [] + tmp = [] # grab the first token, ignoring whitespace token = token_list.token_next(0) - tmp = [] while token and not token.match(sqlparse.tokens.Punctuation, ')'): tmp.append(token) idx = token_list.token_index(token) # grab the next token, this times including whitespace token = token_list.token_next(idx, skip_ws=False) # split on ",", except when on end of statement - if token is not None \ - and token.match(sqlparse.tokens.Punctuation, ','): + if token and token.match(sqlparse.tokens.Punctuation, ','): definitions.append(tmp) tmp = [] idx = token_list.token_index(token) diff --git a/examples/extract_table_names.py b/examples/extract_table_names.py index 3ab04a9..b43ee5f 100644 --- a/examples/extract_table_names.py +++ b/examples/extract_table_names.py @@ -1,6 +1,14 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright (C) 2016 Andi Albrecht, albrecht.andi@gmail.com +# +# This example is part of python-sqlparse and is released under +# the BSD License: http://www.opensource.org/licenses/bsd-license.php +# # This example illustrates how to extract table names from nested # SELECT statements. - +# # See: # http://groups.google.com/group/sqlparse/browse_thread/thread/b0bd9a022e9d4895 |
