def _get_sql(data, files=None):
sql = None
if files is not None and 'datafile' in files:
raw = files['datafile'].read()
try:
sql = raw.decode('utf-8')
except UnicodeDecodeError, err:
logging.error(err)
logging.debug(repr(raw))
sql = (u'-- UnicodeDecodeError: %s\n'
u'-- Please make sure to upload UTF-8 encoded data for now.\n'
u'-- If you want to help improving this part of the application\n'
u'-- please file a bug with some demo data at:\n'
u'-- http://code.google.com/p/python-sqlparse/issues/entry\n'
u'-- Thanks!\n' % err)
if not sql:
sql = data.get('data')
return sql or ''
评论列表
文章目录