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)
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
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
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
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
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
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
def db_command(self): cur = pjson_db.cursor() cur.execute( "SELECT * FROM pjson_main WHERE data ->> 'str1' = '{}';".format(self.arguments[0]) ) return cur
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
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
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
def db_command(self): cur = pjson_db.cursor() cur.execute("SELECT data -> 'str1' AS str1, data -> 'num' AS num FROM pjson_main;") return cur
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
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])