julia postgres libpq update example

The Julia community seems shy about posting examples of database things…

use LibPQ, Tables

db="db" 
server="localhost" 
usr="psql"
passwd="nope"

conn = LibPQ.Connection("host=$server dbname=$db user=$usr password=$passwd")
sql = """select char from foo""" 

conn2 = LibPQ.Connection("host=$server dbname=$db user=$usr password=$passwd") 
sql2 = prepare(conn2, """update bar set agility = \$1 , bravery = \$2 where char = \$3""" ) 

response = execute(conn, sql) 

for row in rowtable(response)
  ag = agility(row[:char])
  br = bravery(row[:char])
  execute(sql2, (ag, br, row[:char]))
end

julia mysql mariadb dbinterface update

https://github.com/JuliaDatabases/DBInterface.jl  mariadb — mysql

while doing a query on “conn”, I opended second connection “conn2”, and updated the table while stepping through the results of the first query

conn = DBInterface.connect(MySQL.Connection,"localhost","user","pass",db="foo")
sql = """select char from foo"""
response = DBInterface.execute(conn,sql)
conn2 = DBInterface.connect(MySQL.Connection,"localhost","user","pass",db="foo")
sql2 = DBInterface.prepare(conn2, "UPDATE foo set agility = ?, bravery = ? where character = ?")
for row in response
    ag=agility(char)
    br=bravery(char)
    DBInterface.execute(sql2, (ag, br, char))
end

julia complains without the parens around the arguments on the DBInterace.execute line.