Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install sqlparse

How to install sqlparse

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install sqlparse
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1.4
0.1.8Never BuiltWhy not?
0.1.4 Available View build log
0.1.3 Available View build log
0.1.2 Available View build log
0.1.1 Available View build log
Windows (64-bit)
0.1.4
0.1.8Never BuiltWhy not?
0.1.4 Available View build log
0.1.3 Available View build log
0.1.2 Available View build log
0.1.1 Available View build log
Mac OS X (10.5+)
0.1.4
0.1.8Never BuiltWhy not?
0.1.4 Available View build log
0.1.3 Available View build log
0.1.2 Available View build log
0.1.1 Available View build log
Linux (32-bit)
0.1.8 Available View build log
0.1.4 Available View build log
0.1.3 Available View build log
0.1.2 Available View build log
0.1.1 Available View build log
Linux (64-bit)
0.1.8 Available View build log
0.1.6 Available View build log
0.1.4 Available View build log
0.1.3 Available View build log
0.1.2 Available View build log
0.1.1 Available View build log
0.1.8 Available View build log
0.1.6 Available View build log
 
Author
License
BSD
Lastest release
version 0.1.8 on Jul 4th, 2013

sqlparse is a non-validating SQL parser module. It provides support for parsing, splitting and formatting SQL statements.

Visit the project page for additional information and documentation.

Example Usage

Splitting SQL statements:

>>> import sqlparse
>>> sqlparse.split('select * from foo; select * from bar;')
[u'select * from foo; ', u'select * from bar;']

Formatting statemtents:

>>> sql = 'select * from foo where id in (select id from bar);'
>>> print sqlparse.format(sql, reindent=True, keyword_case='upper')
SELECT *
FROM foo
WHERE id IN
  (SELECT id
   FROM bar);

Parsing:

>>> sql = 'select * from someschema.mytable where id = 1'
>>> res = sqlparse.parse(sql)
>>> res
(<Statement 'select...' at 0x9ad08ec>,)
>>> stmt = res[0]
>>> unicode(stmt)  # converting it back to unicode
u'select * from someschema.mytable where id = 1'
>>> # This is how the internal representation looks like:
>>> stmt.tokens
(<DML 'select' at 0x9b63c34>,
 <Whitespace ' ' at 0x9b63e8c>,
 <Operator '*' at 0x9b63e64>,
 <Whitespace ' ' at 0x9b63c5c>,
 <Keyword 'from' at 0x9b63c84>,
 <Whitespace ' ' at 0x9b63cd4>,
 <Identifier 'somes...' at 0x9b5c62c>,
 <Whitespace ' ' at 0x9b63f04>,
 <Where 'where ...' at 0x9b5caac>)

Subscribe to package updates

Last updated Jul 4th, 2013

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.