Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
news
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sartika Aritonang
news
Commits
d83eb869
Commit
d83eb869
authored
May 29, 2020
by
Sartika Aritonang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
afc8c5bc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
0 deletions
+72
-0
__init__.py
stbi/Lib/site-packages/sqlparse/__init__.py
+72
-0
No files found.
stbi/Lib/site-packages/sqlparse/__init__.py
0 → 100644
View file @
d83eb869
# -*- coding: utf-8 -*-
#
# Copyright (C) 2009-2018 the sqlparse authors and contributors
# <see AUTHORS file>
#
# This module is part of python-sqlparse and is released under
# the BSD License: https://opensource.org/licenses/BSD-3-Clause
"""Parse SQL statements."""
# Setup namespace
from
sqlparse
import
sql
from
sqlparse
import
cli
from
sqlparse
import
engine
from
sqlparse
import
tokens
from
sqlparse
import
filters
from
sqlparse
import
formatter
from
sqlparse.compat
import
text_type
__version__
=
'0.3.1'
__all__
=
[
'engine'
,
'filters'
,
'formatter'
,
'sql'
,
'tokens'
,
'cli'
]
def
parse
(
sql
,
encoding
=
None
):
"""Parse sql and return a list of statements.
:param sql: A string containing one or more SQL statements.
:param encoding: The encoding of the statement (optional).
:returns: A tuple of :class:`~sqlparse.sql.Statement` instances.
"""
return
tuple
(
parsestream
(
sql
,
encoding
))
def
parsestream
(
stream
,
encoding
=
None
):
"""Parses sql statements from file-like object.
:param stream: A file-like object.
:param encoding: The encoding of the stream contents (optional).
:returns: A generator of :class:`~sqlparse.sql.Statement` instances.
"""
stack
=
engine
.
FilterStack
()
stack
.
enable_grouping
()
return
stack
.
run
(
stream
,
encoding
)
def
format
(
sql
,
encoding
=
None
,
**
options
):
"""Format *sql* according to *options*.
Available options are documented in :ref:`formatting`.
In addition to the formatting options this function accepts the
keyword "encoding" which determines the encoding of the statement.
:returns: The formatted SQL statement as string.
"""
stack
=
engine
.
FilterStack
()
options
=
formatter
.
validate_options
(
options
)
stack
=
formatter
.
build_filter_stack
(
stack
,
options
)
stack
.
postprocess
.
append
(
filters
.
SerializerUnicode
())
return
u''
.
join
(
stack
.
run
(
sql
,
encoding
))
def
split
(
sql
,
encoding
=
None
):
"""Split *sql* into single statements.
:param sql: A string containing one or more SQL statements.
:param encoding: The encoding of the statement (optional).
:returns: A list of strings.
"""
stack
=
engine
.
FilterStack
()
return
[
text_type
(
stmt
)
.
strip
()
for
stmt
in
stack
.
run
(
sql
,
encoding
)]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment