2023-01-23

PostgreSQLClientKit querying database

Is there a short way to prepare the statements and execute them, if you are trying to run multiple queries and you are not concerned with the results that are generated by those statements.

Forexample I want to execute these two statements, is there any short way to write these two statements and execute them.

do{
        let load_age_statement = try connection.prepareStatement(text: "Load 'age';")
        let set_path_statement = try connection.prepareStatement(text: "SET search_path = ag_catalog, '$user', public;")
    
        var cursor = try load_age_statement.execute()
        load_age_statement.close()
        cursor  = try set_path_statement.execute()
        
}catch{
        print(error)
}


No comments:

Post a Comment