# -*- coding: utf-8 -*-
"""只操作本程序创建的临时对象；全部数据为合成样本。"""
import os, sys, json, sqlite3, tempfile, pathlib, subprocess, time, socket, stat
from pathlib import Path
def emit(**kw):
    print(json.dumps(kw, ensure_ascii=False, sort_keys=True))
c=sqlite3.connect(':memory:'); c.execute('CREATE TABLE tenants(id TEXT PRIMARY KEY)'); c.executemany('INSERT INTO tenants VALUES(?)',[("A",),("B",),("O'Reilly",)])
def find(ids):
    if not ids: return []
    return [r[0] for r in c.execute('SELECT id FROM tenants WHERE id IN ('+','.join('?' for _ in ids)+') ORDER BY id',ids)]
out=[find(['A','B']),find(["O'Reilly"]),find([]),find(["A') OR 1=1 --"])]
assert out==[['A','B'],["O'Reilly"],[],[]] and c.execute('SELECT count(*) FROM tenants').fetchone()[0]==3
emit(results=out,table_rows=3)
