LoginSignup
0
0

Julia: PostgreSQL のデータを読む (Read)

Last updated at Posted at 2021-12-28
postgre_read.jl
#! /usr/bin/julia
#
#	postgre_read.jl
#
#						Dec/28/2021
# --------------------------------------------------------------------
using LibPQ
using DotEnv
# --------------------------------------------------------------------
println("*** 開始 ***")
cfg=DotEnv.config()
user=cfg["user"]
password=cfg["password"]
data_base=cfg["data_base"]

str_connect = "dbname= " * data_base * " host=127.0.0.1 user=scott password=tiger123 port=5432"
conn = LibPQ.Connection(str_connect)
command = "select * from cities"
results = execute(conn, command)
for row in results
	print(row[1],'\t',row[2],'\t')
	println(row[3],'\t',row[4])
end
#
close(conn)
#
println("*** 終了 ***")
# --------------------------------------------------------------------

確認したバージョン

$ julia --version
julia version 1.10.2
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0