Parameterizing the IN operator for sqlite

A minor thing, but I searched about it so I thought I'd write about it.

I can now define particular stars as part of a constellation and have added the ability of my constellation model to only pull selected stars from the database.

I'm using the IN operator in my SQL SELECT query and tried looking to see if there was a list handler for parameterizing SQL sets. A quick search brought up nothing and I just ended up writing this.

    def generate_sql_in_parts(col_name, query_set):
        sql_keys = []
        sql_data = {}
        for i, member in enumerate(query_set):
            key = 'i{}'.format(i)
            sql_data[key] = member

        sql_str = "{} IN ({})".format(col_name, ",".join(sql_keys))
        return sql_str, sql_data

With sqlstr and sqldata later incorporated into a full SELECT statement.

Nothing groundbreaking, and code that has been written a thousand times, but there it is. I've become accustomed SQLAlchemy and Django ORM, it's nice to have good tools.