MCPcopy Create free account
hub / github.com/HexHive/NASS / init_db

Function init_db

data/interface_db.py:14–66  ·  view source on GitHub ↗
(BINDER_DB)

Source from the content-addressed store, hash-verified

12from instrument.lib import NativeFunction, onTransactFunction
13
14def init_db(BINDER_DB):
15 connection = sqlite3.connect(BINDER_DB)
16 cursor = connection.cursor()
17 create_table_query = """
18 CREATE TABLE IF NOT EXISTS service (
19 id INTEGER PRIMARY KEY,
20 device TEXT,
21 service_name TEXT,
22 binary_path TEXT,
23 arch TEXT,
24 is_app INTEGER,
25 is_svcsvr INTEGER,
26 is_native INTEGER,
27 onTransact_bin TEXT,
28 onTransact_entry INTEGER,
29 onTransact_last INTEGER,
30 onTransact_fname TEXT,
31 onTransact_module TEXT,
32 onTransact_interface TEXT,
33 onTransact_md5 TEXT,
34 onTransact_BBinder TEXT,
35 cmd_ids_enumerated INTEGER,
36 CONSTRAINT unqs UNIQUE (device, service_name)
37 );
38 """
39 cursor.execute(create_table_query)
40 create_table_query = """
41 CREATE TABLE IF NOT EXISTS interface (
42 id INTEGER PRIMARY KEY,
43 service_id INTEGER,
44 cmd_id INTEGER,
45 valid INTEGER,
46 args_enumerated INTEGER,
47 FOREIGN KEY(service_id) REFERENCES service(id),
48 CONSTRAINT unqi UNIQUE (service_id, cmd_id)
49 );
50 """
51 cursor.execute(create_table_query)
52 create_table_query = """
53 CREATE TABLE IF NOT EXISTS args (
54 id INTEGER PRIMARY KEY,
55 interface_id INTEGER,
56 ordering INTEGER,
57 type TEXT,
58 info TEXT,
59 constr TEXT,
60 FOREIGN KEY(interface_id) REFERENCES interface(id),
61 CONSTRAINT unqa UNIQUE (interface_id, ordering)
62 );
63 """
64 cursor.execute(create_table_query)
65 cursor.close()
66 connection.close()
67
68
69def insert_arg(connection, interface_id, arg:Arg, order):

Callers

nothing calls this directly

Calls 2

connectMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected