Update sqlite3-python/README.md
This commit is contained in:
@@ -13,17 +13,16 @@ sql("SELECT * FROM sqlite_master WHERE type = 'table'")
|
||||
def SQL():
|
||||
from sqlite3 import connect, Row
|
||||
(con := connect('.db.sql', isolation_level=None)).row_factory = Row
|
||||
sql = type('', (), dict(
|
||||
con.execute('PRAGMA journal_mode=wal')
|
||||
con.execute('PRAGMA busy_timeout='f'{1e9}')
|
||||
con.execute('CREATE TABLE IF NOT EXISTS kv(k PRIMARY KEY, v)')
|
||||
return (sql := type('', (), dict(
|
||||
__call__=lambda _, q, *p: list(map(dict, con.execute(q, p))),
|
||||
__iter__=lambda sql: (kv.values() for kv in sql('SELECT * FROM kv')),
|
||||
__getitem__=lambda sql, k: sql('SELECT v FROM kv WHERE k=?', k)[0]['v'],
|
||||
__setitem__=lambda sql, k, v:
|
||||
sql('INSERT or REPLACE INTO kv VALUES(?,?)', k, v),
|
||||
))()
|
||||
sql('PRAGMA journal_mode=wal')
|
||||
sql('PRAGMA busy_timeout='f'{1e9}')
|
||||
sql('CREATE TABLE IF NOT EXISTS kv(k PRIMARY KEY, v)')
|
||||
return sql
|
||||
))())
|
||||
sql = SQL()
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user