Skip to content

Commit

Permalink
Fix compatibility with SQLite prior to 3.16.0
Browse files Browse the repository at this point in the history
pragma_index_info() and pragma_index_list() were introduced in 3.16.0 but the
version of SQLite running in Travis CI is earlier than that, hence the test
failures:

https://travis-ci.com/simonw/sqlite-utils/jobs/137617744
  • Loading branch information
Simon Willison committed Aug 1, 2018
1 parent 4427d2d commit 0aa2829
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sqlite_utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ def schema(self):

@property
def indexes(self):
sql = "select * from pragma_index_list(?)"
sql = 'PRAGMA index_list("{}")'.format(self.name)
indexes = []
for row in list(self.db.conn.execute(sql, (self.name,)).fetchall()):
column_sql = "select name from pragma_index_info(?) order by seqno"
columns = [
r[0] for r in self.db.conn.execute(column_sql, (row[1],)).fetchall()
]
for row in list(self.db.conn.execute(sql).fetchall()):
column_sql = 'PRAGMA index_info("{}")'.format(row[1])
columns = []
for seqno, cid, name in self.db.conn.execute(column_sql).fetchall():
columns.append(name)
indexes.append(Index(*(row + (columns,))))
return indexes

Expand Down

0 comments on commit 0aa2829

Please sign in to comment.