Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions scraperwiki/sql.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

DATABASE_TIMEOUT = float(os.environ.get("SCRAPERWIKI_DATABASE_TIMEOUT", 300))
SECONDS_BETWEEN_COMMIT = 2
unicode = type(u'')
unicode = str

# The scraperwiki.sqlite.SqliteError exception
SqliteError = sqlalchemy.exc.SQLAlchemyError
Expand All @@ -28,7 +28,7 @@ class Blob(bytes):
Represents a blob as a string.
"""
PYTHON_SQLITE_TYPE_MAP = {
six.text_type: sqlalchemy.types.Text,
str: sqlalchemy.types.Text,
str: sqlalchemy.types.Text,
int: sqlalchemy.types.BigInteger,
bool: sqlalchemy.types.Boolean,
Expand All @@ -50,7 +50,7 @@ class Blob(bytes):
pass


class _State(object):
class _State:

"""
This class maintains global state relating to the database such as
Expand Down Expand Up @@ -105,7 +105,7 @@ def check_last_committed(cls):
cls.new_transaction()


class Transaction(object):
class Transaction:

"""
This context manager must be used when other services need
Expand Down Expand Up @@ -159,9 +159,9 @@ def execute(query, data=None):
pass

if not result.returns_rows:
return {u'data': [], u'keys': []}
return {'data': [], 'keys': []}

return {u'data': result.fetchall(), u'keys': list(result.keys())}
return {'data': result.fetchall(), 'keys': list(result.keys())}


def select(query, data=None):
Expand Down Expand Up @@ -310,7 +310,7 @@ def get_var(name, default=None):

# This is to do the variable type conversion through the SQL engine
execute = connection.execute
execute("CREATE TEMPORARY TABLE _sw_tmp ('value' {})".format(result.type))
execute(f"CREATE TEMPORARY TABLE _sw_tmp ('value' {result.type})")
execute("INSERT INTO _sw_tmp VALUES (:value)", value=result.value_blob)
var = execute('SELECT value FROM _sw_tmp').fetchone().value
execute("DROP TABLE _sw_tmp")
Expand Down
2 changes: 1 addition & 1 deletion scraperwiki/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def pdftoxml(pdfdata, options=""):

xmlin = tempfile.NamedTemporaryFile(mode='r', suffix='.xml')
tmpxml = xmlin.name # "temph.xml"
cmd = 'pdftohtml -xml -nodrm -zoom 1.5 -enc UTF-8 -noframes %s "%s" "%s"' % (
cmd = 'pdftohtml -xml -nodrm -zoom 1.5 -enc UTF-8 -noframes {} "{}" "{}"'.format(
options, pdffout.name, os.path.splitext(tmpxml)[0])
# can't turn off output, so throw away even stderr yeuch
cmd = cmd + " >/dev/null 2>&1"
Expand Down
Loading