MCPcopy Create free account
hub / github.com/SeldonIO/seldon-server / addAttrsToDb

Function addAttrsToDb

python/seldon/cli/attr_schema_utils.py:15–42  ·  view source on GitHub ↗
(db, attrs, item_type)

Source from the content-addressed store, hash-verified

13 text='TEXT', enum='ENUM')
14
15def addAttrsToDb(db, attrs, item_type):
16 attrs.append({"name":"content_type", "value_type":["article"]})
17 for attr in attrs:
18 attrValType = attr['value_type']
19 if type(attrValType) is list:
20 attrValType = 'enum'
21 cur = db.cursor()
22 cur.execute("INSERT INTO ITEM_ATTR (name, type, item_type) "
23 + " VALUES (%s, %s, %s)", (attr['name'], value_types_to_db_map[attrValType], item_type))
24 if attrValType is 'enum':
25 for index,enum in enumerate(attr['value_type'], start=1):
26 cur = db.cursor()
27 cur.execute("SELECT attr_id FROM ITEM_ATTR WHERE NAME = %s and ITEM_TYPE = %s", (attr['name'],item_type))
28 rows = cur.fetchall()
29 attrId = rows[0][0]
30 cur = db.cursor()
31 cur.execute("INSERT INTO ITEM_ATTR_ENUM (attr_id, value_id, value_name) VALUES (%s, %s, %s)",(attrId, index, enum))
32 cur = db.cursor()
33
34 cur.execute("SELECT attr_id, value_id, value_name FROM ITEM_ATTR_ENUM")
35 rows = cur.fetchall()
36 for row in rows:
37 enum_attr_id = row[0]
38 enum_value_id = row[1]
39 enum_value_name = row[2]
40 cur = db.cursor()
41 cur.execute("INSERT INTO DIMENSION (item_type, attr_id, value_id) VALUES"
42 + " (%s, %s, %s)", (item_type, enum_attr_id, enum_value_id))
43
44def doDbChecks(db):
45 cur = db.cursor()

Callers 1

addToDbFunction · 0.70

Calls 1

executeMethod · 0.65

Tested by

no test coverage detected