1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Xojo + MySQL(MariaDB) で日本語カラム名

Last updated at Posted at 2020-03-23

日本語カラム名や日本語テーブル名を用いた MySQL(MariaDB) を Xojo で使うやり方。

環境

  • Ubuntu 18.04 AMD64
  • Xojo 2019 r3.1
  • (MySQL) 10.1.44-MariaDB-0ubuntu0.18.04.1 Ubuntu 18.04

なお、MS-Windows でも同様にテストしたが、 Xojo に組み込まれている MySQL のドライバだと解決できない感じ。

接続


self.db = New MySQLCommunityServer
self.db.Host = "127.0.0.1"    // "localhost" ではNG
self.db.UserName = "xojodb"
self.db.Password = "password"
self.db.DatabaseName = "test"
Try
  self.db.Connect
  // proceed with database operations here..
Catch error As DatabaseException
  MessageBox("The database couldn't be opened. Error: " + error.Message)
  Return
End Try
try
  self.db.SQLExecute("set names utf8 collate utf8_general_ci")
  self.db.SQLExecute("set character set utf8")
  self.db.SQLExecute("use test")
Catch error as DatabaseException
  MessageBox error.Message
end try

set names utf8 collate utf8_general_ci

set character set utf8
を実行しておく必要がある。

試したSQL

この設定で、以下のSQLが正常に動作した。

INSERT文


app.db.ExecuteSQL("INSERT INTO sensorJP ( センサ,温度,湿度,memo) VALUES (2,"+temp+","+hemi+",'換気中');")

Select文


rsJP =app.db.SelectSQL("SELECT id,温度,湿度,memo FROM sensorJP")

1
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?