1
2
3
4
5
6
7
8
9
10
11
12
13
14 """
15 This class contains functions to build PostgreSQL string and query to insert Victor Models table.
16 """
17
18 victor_models = "VICTOR_MODELS"
19
20
21
22
23
24
26 """
27 Builds PostgreSQL string from the given string parameter
28 @type v: string
29 @param v: the string that will be used to build PostgreSQL string
30
31 @rtype: string
32 @return: returns 'v' (PostgreSQL string)
33 """
34 if not v:
35 return "NULL"
36 else:
37 return ''.join(["'", v, "'"])
38
40 """
41 Constructs PostgreSQL query to insert given model to the victor models table
42 @type model_name: string
43 @param model_name: name of the model
44 @type objective_all: string
45 @param objective_all: objectivea ll
46 @type objective_item: string
47 @param objective_item: objective item
48 @type gradient: string
49 @param gradient: gradient
50 @type prox: string
51 @param prox: prox
52 @type model_type: string
53 @param model_type: type of the model
54 @type data_type: string
55 @param data_type: type of the data
56
57 @rtype: string
58 @return: returns insert query
59 """
60 v = [model_name, objective_all, objective_item, model_type, data_type, gradient, prox]
61 vv = [build_string_constant(vi) for vi in v]
62 vals = ','.join(vv)
63 st = ["INSERT INTO ", victor_models, " VALUES (", vals, ");\n"]
64 return ''.join(st)
65
66
67
68
69
70
71
72
73
74
75
76