# -*- 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("CREATE TABLE channels(id PRIMARY KEY,body,version); INSERT INTO channels VALUES(1,'old',7);")
first=c.execute('UPDATE channels SET body=?,version=version+1 WHERE id=? AND version=?',('first',1,7)).rowcount
stale=c.execute('UPDATE channels SET body=?,version=version+1 WHERE id=? AND version=?',('stale',1,7)).rowcount
final=c.execute('SELECT body,version FROM channels').fetchone(); assert first==1 and stale==0 and final==('first',8)
emit(first_rows=first,stale_rows=stale,final=final,sample_http_status=409 if stale==0 else 200)
