Skip to content

Instantly share code, notes, and snippets.

@tomohisa
Created May 24, 2016 14:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomohisa/fd87306d2e0002e90a7db73f51cb37c7 to your computer and use it in GitHub Desktop.
Save tomohisa/fd87306d2e0002e90a7db73f51cb37c7 to your computer and use it in GitHub Desktop.
code for SimpleMySQLClassGenerator
// Change below parameters to match your Environment
struct Constants: ConnectionOption {
var host: String = "127.0.0.1"
var port: Int = 3306
var user: String = "root"
var password: String = "CHANGE_TO_YOUR_PASSWORD"
var database: String = "CHANGE_TO_YOUR_PASSWORD"
var encoding: MySQL.Connection.Encoding = .UTF8MB4
var timeZone: MySQL.Connection.TimeZone = MySQL.Connection.TimeZone(GMTOffset: 60 * 60 * 9) // JST
}
do {
let constants = Constants()
let pool = ConnectionPool(options: constants)
try pool.execute { conn in
let tables : [TableList] = try conn.query("select * from tblList")
print(tables)
}
print("successfully finished")
} catch let error {
print("error\(error)")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment