{"id":339,"date":"2021-06-02T05:44:39","date_gmt":"2021-06-02T05:44:39","guid":{"rendered":"https:\/\/randomlinuxnotes.d13.com\/?p=339"},"modified":"2021-06-02T05:44:39","modified_gmt":"2021-06-02T05:44:39","slug":"libpq-update-example","status":"publish","type":"post","link":"https:\/\/randomlinuxnotes.d13.com\/?p=339","title":{"rendered":"julia postgres libpq update example"},"content":{"rendered":"<p>The Julia community seems shy about posting examples of database things&#8230;<\/p>\n<pre>\nuse LibPQ, Tables\n\ndb=\"db\" \nserver=\"localhost\" \nusr=\"psql\"\npasswd=\"nope\"\n\nconn = LibPQ.Connection(\"host=$server dbname=$db user=$usr password=$passwd\")\nsql = \"\"\"select char from foo\"\"\" \n\nconn2 = LibPQ.Connection(\"host=$server dbname=$db user=$usr password=$passwd\") \nsql2 = prepare(conn2, \"\"\"update bar set agility = \\$1 , bravery = \\$2 where char = \\$3\"\"\" ) \n\nresponse = execute(conn, sql) \n\nfor row in rowtable(response)\n  ag = agility(row[:char])\n  br = bravery(row[:char])\n  execute(sql2, (ag, br, row[:char]))\nend\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>The Julia community seems shy about posting examples of database things&#8230; use LibPQ, Tables db=&#8221;db&#8221; server=&#8221;localhost&#8221; usr=&#8221;psql&#8221; passwd=&#8221;nope&#8221; conn = LibPQ.Connection(&#8220;host=$server dbname=$db user=$usr password=$passwd&#8221;) sql = &#8220;&#8221;&#8221;select char from foo&#8221;&#8221;&#8221; conn2 = LibPQ.Connection(&#8220;host=$server dbname=$db user=$usr password=$passwd&#8221;) sql2 = prepare(conn2, &#8220;&#8221;&#8221;update bar set agility = \\$1 , bravery = \\$2 where [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[64,67,107,146],"class_list":["post-339","post","type-post","status-publish","format-standard","hentry","category-rln","tag-julia","tag-libpq","tag-postgres","tag-update"],"_links":{"self":[{"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=\/wp\/v2\/posts\/339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=339"}],"version-history":[{"count":0,"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=\/wp\/v2\/posts\/339\/revisions"}],"wp:attachment":[{"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomlinuxnotes.d13.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}