Created
May 24, 2016 14:55
-
-
Save tomohisa/fd87306d2e0002e90a7db73f51cb37c7 to your computer and use it in GitHub Desktop.
code for SimpleMySQLClassGenerator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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