# -*- 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.executescript('PRAGMA foreign_keys=OFF; CREATE TABLE parent(id INTEGER PRIMARY KEY); CREATE TABLE child(id INTEGER PRIMARY KEY,pid REFERENCES parent(id)); INSERT INTO child VALUES(1,99); PRAGMA foreign_keys=ON;')
physical=c.execute('PRAGMA integrity_check').fetchall(); orphan=c.execute('PRAGMA foreign_key_check').fetchall()
c.execute('INSERT INTO parent VALUES(99)'); after=c.execute('PRAGMA foreign_key_check').fetchall()
assert physical==[('ok',)] and orphan==[('child',1,'parent',0)] and after==[]
emit(integrity_check=physical,foreign_key_check=orphan,after_repair=after)
