Skip to content

Commit

Permalink
Update init and misc files
Browse files Browse the repository at this point in the history
  • Loading branch information
vmuriart committed Jun 6, 2016
1 parent c43fccf commit b114ff6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 21 deletions.
13 changes: 9 additions & 4 deletions examples/column_defs_lowlevel.py
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -21,17 +27,16 @@
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)
Expand Down
10 changes: 9 additions & 1 deletion examples/extract_table_names.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
7 changes: 7 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
[wheel]
universal = 1

[flake8]
exclude =
sqlparse/compat.py
ignore =
W503,
E731
17 changes: 9 additions & 8 deletions sqlparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion sqlparse/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ def unicode_compatible(cls):


text_type = unicode
string_types = (basestring,)
string_types = (str, unicode,)
from StringIO import StringIO
7 changes: 0 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,3 @@ deps =
flake8
commands =
flake8 sqlparse tests setup.py

[flake8]
exclude =
sqlparse/compat.py
ignore =
W503,
E731

0 comments on commit b114ff6

Please sign in to comment.