summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Uriarte <victor.m.uriarte@intel.com>2016-06-05 14:59:38 -0700
committerVictor Uriarte <victor.m.uriarte@intel.com>2016-06-06 07:55:39 -0700
commitb114ff6361550246cb5cb96168d25fe46bd355ef (patch)
treeb998ea09ac3317c0c2c2eec4b009eb601c920477
parentc43fccfefed0806cca52bea48d232ddf72f842cd (diff)
downloadsqlparse-b114ff6361550246cb5cb96168d25fe46bd355ef.tar.gz
Update init and misc files
-rw-r--r--examples/column_defs_lowlevel.py13
-rw-r--r--examples/extract_table_names.py10
-rw-r--r--setup.cfg7
-rw-r--r--sqlparse/__init__.py17
-rw-r--r--sqlparse/compat.py2
-rw-r--r--tox.ini7
6 files changed, 35 insertions, 21 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
diff --git a/setup.cfg b/setup.cfg
index 5e40900..c3bf82b 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,2 +1,9 @@
[wheel]
universal = 1
+
+[flake8]
+exclude =
+ sqlparse/compat.py
+ignore =
+ W503,
+ E731
diff --git a/sqlparse/__init__.py b/sqlparse/__init__.py
index cb83a71..e5baf4c 100644
--- a/sqlparse/__init__.py
+++ b/sqlparse/__init__.py
@@ -7,16 +7,17 @@
"""Parse SQL statements."""
-
-__version__ = '0.2.0.dev0'
-
-
# Setup namespace
-from sqlparse import engine # noqa
-from sqlparse import filters # noqa
-from sqlparse import formatter # noqa
+from sqlparse import sql
+from sqlparse import engine
+from sqlparse import tokens
+from sqlparse import filters
+from sqlparse import formatter
+
+from sqlparse.compat import u
-from sqlparse.compat import u # noqa
+__version__ = '0.2.0.dev0'
+__all__ = ['engine', 'filters', 'formatter', 'sql', 'tokens']
def parse(sql, encoding=None):
diff --git a/sqlparse/compat.py b/sqlparse/compat.py
index 0defd86..a41b18b 100644
--- a/sqlparse/compat.py
+++ b/sqlparse/compat.py
@@ -50,5 +50,5 @@ elif PY2:
text_type = unicode
- string_types = (basestring,)
+ string_types = (str, unicode,)
from StringIO import StringIO
diff --git a/tox.ini b/tox.ini
index 265cc3c..6c27e70 100644
--- a/tox.ini
+++ b/tox.ini
@@ -26,10 +26,3 @@ deps =
flake8
commands =
flake8 sqlparse tests setup.py
-
-[flake8]
-exclude =
- sqlparse/compat.py
-ignore =
- W503,
- E731