Julia: 更新 MariaDB 的数据 (Update)

程式

文件夹结构

$ tree -a
.
├── .env
├── config_mariadb.jl
└── maria_update.jl
#! /usr/bin/julia
#
#	maria_update.jl
#
#						Feb/24/2023
# --------------------------------------------------------------------
using MySQL
include("config_mariadb.jl")
# --------------------------------------------------------------------
println(stderr,"*** 開始 ***")
key_in = ARGS[1]
population_in = ARGS[2]
println(key_in,'\t',population_in)
#
today = Libc.strftime("%F", time())
println(today)

host, user, password, data_base = config_mariadb_proc()
conn =DBInterface.connect(MySQL.Connection, host, user, password)

command = "update " * data_base * ".cities" * " set population = " * population_in
command *= " , date_mod = '" * today * "'"
command *= " where id = '" * key_in * "'"
println(command)
#
results = DBInterface.execute(conn,command)
println(results)
#
DBInterface.close!(conn)
#
println(stderr,"*** 終了 ***")
# --------------------------------------------------------------------

.env
config_mariadb.jl
在这里
Julia:显示MariaDB的版本

确认的版本

$ julia -v
julia version 1.8.5