LoginSignup
0
0

More than 1 year has passed since last update.

Julia: MariaDB のバージョンを表示

Last updated at Posted at 2023-02-24

プログラム

フォルダー構造

$ tree -a
.
├── .env
├── config_mariadb.jl
└── server_version.jl
server_version.jl
#! /usr/bin/julia
#
#	server_version.jl
#
#						Feb/24/2023
# --------------------------------------------------------------------
using MySQL

include("config_mariadb.jl")
# --------------------------------------------------------------------
println(stderr,"*** 開始 ***")

host, user, password, data_base = config_mariadb_proc() 
conn =DBInterface.connect(MySQL.Connection, host, user, password)
command = "SELECT VERSION ()"
println(command)
#
results = DBInterface.execute(conn,command)
#
for row in results
	println(row)
end
DBInterface.close!(conn)
#
println(stderr,"*** 終了 ***")
# --------------------------------------------------------------------
config_mariadb.jl
#
#	config_mariadb.jl
#
#						Feb/24/2023
# --------------------------------------------------------------------
using DotEnv
# --------------------------------------------------------------------
function config_mariadb_proc()
	DotEnv.config()
	host=ENV["host"]
	user=ENV["user"]
	password=ENV["password"]
	data_base=ENV["data_base"]
#
	return host, user, password, data_base
end
# --------------------------------------------------------------------
.env
host = '127.0.0.1'
user = 'scott'
password = 'tiger123'
data_base = 'city'

実行結果

$ ./server_version.jl 
*** 開始 ***
SELECT VERSION ()
MySQL.TextRow{true}:
 Symbol("VERSION ()")  "10.11.2-MariaDB"
*** 終了 ***

確認したバージョン

$ julia -v
julia version 1.8.5
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