def db():
conn = GreenConnection(host='localhost')
try:
with conn as cur:
print('>> sleeping')
st = time.monotonic()
cur.execute('SELECT SLEEP(2)')
en = time.monotonic() - st
assert en >= 2
print('<< sleeping {:.3f}s'.format(en))
cur.execute('SELECT 42')
print('"SELECT 42" -> {!r}'.format(cur.fetchone()))
print('>> sleeping')
st = time.monotonic()
cur.execute('SELECT SLEEP(1)')
en = time.monotonic() - st
assert en >= 1
print('<< sleeping {:.3f}s'.format(en))
finally:
conn.close()
评论列表
文章目录