Skip to content

mis-quoted string literal #176

Open
@theavey

Description

@theavey

Hi there: this package started failing for me today with libsqlite=3.49.1

It is complaining about this query:

GET_TABLENAMES = 'SELECT name FROM sqlite_master WHERE type="table"'

According to the sqlite docs, table should be a string-literal in single quotes, not an identifier in double quotes. Not sure what changed in this latest version, but seems that this was always a bit wrong.

File ...\Lib\site-packages\sqlitedict.py:224, in SqliteDict.__init__(self, filename, tablename, flag, autocommit, journal_mode, encode, decode, encode_key, decode_key, timeout, outer_stack)
    222 self.conn = self._new_conn()
    223 if self.flag == 'r':
--> 224     if self.tablename not in SqliteDict.get_tablenames(self.filename):
    225         msg = 'Refusing to create a new table "%s" in read-only DB mode' % tablename
    226         raise RuntimeError(msg)

File ...\Lib\site-packages\sqlitedict.py:365, in SqliteDict.get_tablenames(filename)
    363 GET_TABLENAMES = 'SELECT name FROM sqlite_master WHERE type="table"'
    364 with sqlite3.connect(filename) as conn:
--> 365     cursor = conn.execute(GET_TABLENAMES)
    366     res = cursor.fetchall()
    368 return [name[0] for name in res]

OperationalError: no such column: "table" - should this be a string literal in single-quotes?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions