lua スクリプトで準備済みステートメントを使用したいと考えています。以前の投稿で述べたように、人々はlua-dbi の使用を推奨しています。残念ながら、利用できるドキュメントはほとんどありません。資格情報を使用してデータベースに接続し、準備されたステートメントを使用する基本的なスクリプトが必要です (クエリ内の名前へのバインド関数を使用することをお勧めします)。これを経験した人はいますか?
1129 次
1 に答える
2
プロジェクトの wiki ページで見つけることができます。
接続の確立: https://code.google.com/p/luadbi/wiki/DBDDriverConnection
require('DBI')
-- Create a connection
local dbh = assert(DBI.Connect('Driver', db, username, password, host, port))
-- set the autocommit flag
-- this is turned off by default
dbh:autocommit(true)
-- check status of the connection
local alive = dbh:ping()
-- prepare a connection
local sth = assert(dbh:prepare(sql_string))
-- commit the transaction
dbh:commit()
-- finish up
local ok = dbh:close()
ここで、必要に応じてパーツを更新しdbh:prepare
ます。
于 2015-09-20T10:26:57.323 に答える