Example #1
0
 def db_command(self):
     cur = pjson_db.cursor()
     for tup in self.arguments:
         jsonb_query = (
             "SELECT jsonb_set(data, '{{dyn2}}', '{0}') FROM pjson_main"
             " WHERE data ->> 'num' = '{1}';".format(tup[1], tup[0])
         )
         cur.execute(jsonb_query)
Example #2
0
 def db_command(self):
     search_term = self.arguments[0]
     jsonb_query = "SELECT * from pjson_main WHERE data @> '{0}';".format(
         json.dumps({'nested_arr': [search_term]})
     )
     cur = pjson_db.cursor()
     cur.execute(jsonb_query)
     return cur
Example #3
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute(
         "SELECT * FROM pjson_main WHERE data->>'dyn1' >= '{}' AND data->>'dyn1' < '{}';".format(
             self.arguments[0], self.arguments[1]
         )
     )
     return cur
Example #4
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute(
         "SELECT * FROM pjson_main WHERE CAST(data->>'num' AS integer) >= {}"
         " AND CAST(data->>'num' AS integer) < {};".format(
             self.arguments[0], self.arguments[1]
         )
     )
     return cur
Example #5
0
 def db_command(self):
     jsonb_query = (
         "SELECT * FROM pjson_main"
         " WHERE data #>> '{{deep_nested_obj,level_2,level_3,level_4"
         ",level_5,level_6,level_7,level_8,deep_str_single}}' = '{0}';".format(
             self.arguments[0]
         )
     )
     cur = pjson_db.cursor()
     cur.execute(jsonb_query)
     return cur
Example #6
0
 def db_command(self):
     jsonb_query = (
         "SELECT COUNT(*) FROM pjson_main WHERE CAST(data->>'num' AS integer) >= {}"
         " AND CAST(data->>'num' AS integer) < {}"
         " GROUP BY data->>'thousandth';".format(
             self.arguments[0], self.arguments[1]
         )
     )
     cur = pjson_db.cursor()
     cur.execute(jsonb_query)
     return cur
Example #7
0
 def db_command(self):
     jsonb_query = (
         "SELECT * FROM pjson_main a INNER JOIN pjson_main b"
         " ON (a.data ->> 'str1' = b.data #>> '{{nested_obj,str}}')"
         " WHERE CAST(a.data->>'num' AS integer) >= {}"
         " AND CAST(a.data->>'num' AS integer) < {};".format(
             self.arguments[0], self.arguments[1]
         )
     )
     cur = pjson_db.cursor()
     cur.execute(jsonb_query)
     return cur
Example #8
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute(
         "SELECT * FROM pjson_main WHERE data ->> 'str1' = '{}';".format(self.arguments[0])
     )
     return cur
Example #9
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute("SELECT data -> 'sparse_305' AS sparse_305, data -> 'sparse_991' AS sparse_991 FROM pjson_main WHERE data ?| array['sparse_305', 'sparse_991'];")
     return cur
Example #10
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute("SELECT data -> 'sparse_110' AS sparse_110, data -> 'sparse_119' AS sparse_119 FROM pjson_main WHERE data ?& array['sparse_110', 'sparse_119'];")
     return cur
Example #11
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute("SELECT data #> '{nested_obj,str}' AS nested_str, data #> '{nested_obj,num}' AS nested_num FROM pjson_main;")
     return cur
Example #12
0
 def db_command(self):
     cur = pjson_db.cursor()
     cur.execute("SELECT data -> 'str1' AS str1, data -> 'num' AS num FROM pjson_main;")
     return cur
Example #13
0
 def db_command(self):
     jsonb_query = "SELECT * FROM pjson_main WHERE data ->> 'sparse_500' = '{0}';".format(
         self.arguments[0])
     cur = pjson_db.cursor()
     cur.execute(jsonb_query)
     return cur
Example #14
0
 def prepare(self):
     cur = pjson_db.cursor()
     cur.execute("SELECT data->>'sparse_500' from pjson_main WHERE data ? 'sparse_500';")
     for index, result in enumerate(cur):
         if index == 5:
             self.arguments.append(result[0])