Deno で MariaDB のデータを更新 (Update)
Deno で MariaDB のデータを更新します。
maria_update.ts
// ---------------------------------------------------------------
// maria_update.ts
//
// May/19/2020
//
// ---------------------------------------------------------------
import { Client } from "https://deno.land/x/mysql/mod.ts"
import { config } from "https://deno.land/x/dotenv/mod.ts"
// ---------------------------------------------------------------
function get_current_date_proc ()
{
var today = new Date ()
var ddx = (1900 + today.getFullYear ()) + "-" + (today.getMonth () +1)
ddx += "-" + today.getDate ()
return ddx
}
// ---------------------------------------------------------------
function update_command_gen (id_in:string,population_in:number)
{
const today:string = get_current_date_proc()
var command:string = "update cities set population = " + population_in
command += " , date_mod = '" + today + "'"
command += " where id = '" + id_in + "'"
console.log (command)
return command
}
// ---------------------------------------------------------------
console.log ("*** 開始 ***")
const config_env:any = config()
var id_in:string = Deno.args[0]
var population_in:number = parseInt(Deno.args[1])
console.log (id_in + "\t" + population_in)
const client = await new Client().connect({
hostname: "127.0.0.1",
username: config_env.user,
password: config_env.password,
db: config_env.data_base,
})
const command: string = update_command_gen (id_in,population_in)
const result = await client.query(command)
console.log(result)
console.log ("*** 終了 ***")
// ---------------------------------------------------------------
実行コマンド
deno run --allow-read --allow-net maria_update.ts t3327 16829300
Author And Source
この問題について(Deno で MariaDB のデータを更新 (Update)), 我々は、より多くの情報をここで見つけました https://qiita.com/ekzemplaro/items/b8ceefdc341b7de62718著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .