Use sqlparse to strip comments before finding columns.

This commit is contained in:
Ethan Dalool 2020-02-19 09:49:38 -08:00
parent f7e314f392
commit b66a89268b
2 changed files with 4 additions and 2 deletions

View file

@ -12,6 +12,7 @@ setuptools.setup(
url='https://github.com/voussoir/voussoirkit',
install_requires=[
'pyperclip',
'sqlparse',
'pywin32;platform_system=="Windows"',
'winshell;platform_system=="Windows"',
]

View file

@ -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