Skip to content

Instantly share code, notes, and snippets.

View arvidma's full-sized avatar

Arvid Müllern-Aspegren arvidma

View GitHub Profile
@arvidma
arvidma / sequence_binder.py
Last active March 2, 2023 20:10
Bind tuples to parameterized queries with SQLite on Python
"""
Cross-database compatbile SQLite work-arounds for binding sequences to parameterized queries.
Usage:
bind_pattern, bind_dict = sequence_for_binding( {1, 2, 3} )
query = f"SELECT * FROM mytable WHERE id IN {bind_pattern}"
execute(query, bind_dict)
or, for nested sequences: