Use sqlparse to strip comments before finding columns.
This commit is contained in:
parent
f7e314f392
commit
b66a89268b
2 changed files with 4 additions and 2 deletions
1
setup.py
1
setup.py
|
@ -12,6 +12,7 @@ setuptools.setup(
|
|||
url='https://github.com/voussoir/voussoirkit',
|
||||
install_requires=[
|
||||
'pyperclip',
|
||||
'sqlparse',
|
||||
'pywin32;platform_system=="Windows"',
|
||||
'winshell;platform_system=="Windows"',
|
||||
]
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import re
|
||||
import sqlparse
|
||||
import types
|
||||
|
||||
def delete_filler(pairs):
|
||||
|
@ -162,9 +164,8 @@ def listify(items):
|
|||
return output
|
||||
|
||||
def _extract_create_table_statements(script):
|
||||
script = sqlparse.format(script, strip_comments=True)
|
||||
for statement in script.split(';'):
|
||||
statement = statement.strip()
|
||||
statement = statement.strip('-')
|
||||
statement = statement.strip()
|
||||
if statement.lower().startswith('create table'):
|
||||
yield statement
|
||||
|
|
Loading…
Reference in a new issue