- self.store = sqlite.connect(db=db)
- s = """
- create table kv (key binary, value binary, time timestamp, primary key (key, value));
- create index kv_key on kv(key);
- create index kv_timestamp on kv(time);
-
- create table nodes (id binary primary key, host text, port number);
-
- create table self (num number primary key, id binary);
- """
- c = self.store.cursor()
- c.execute(s)
- self.store.commit()
+ self.conn = sqlite.connect(database=db)
+ c = self.conn.cursor()
+ c.execute("CREATE TABLE kv (key TEXT, value TEXT, time TIMESTAMP, PRIMARY KEY (key, value))")
+ c.execute("CREATE INDEX kv_key ON kv(key)")
+ c.execute("CREATE INDEX kv_timestamp ON kv(time)")
+ c.execute("CREATE TABLE nodes (id TEXT PRIMARY KEY, host TEXT, port NUMBER)")
+ c.execute("CREATE TABLE self (num NUMBER PRIMARY KEY, id TEXT)")
+ self.conn.commit()