1661980680
This library is obsolete and not maintained. Use MySQLNIO instead.
MySQL client library for Swift. This is inspired by Node.js' mysql.
Codable
structs or classesNote: No asynchronous I/O support currently. It depends libmysqlclient.
// Declare a model
struct User: Codable, QueryParameter {
let id: Int
let userName: String
let age: Int?
let status: Status
let createdAt: Date
enum Status: String, Codable {
case created = "created"
case verified = "verified"
}
private enum CodingKeys: String, CodingKey {
case id
case userName = "user_name"
case age
case status = "status"
case createdAt = "created_at"
}
}
// Selecting
let nameParam = "some one"
let ids: [QueryParameter] = [1, 2, 3, 4, 5, 6]
let optionalInt: Int? = nil
let rows: [User] = try conn.query("SELECT id,user_name,status,status,created_at FROM `user` WHERE (age > ? OR age is ?) OR name = ? OR id IN (?)", [50, optionalInt, nameParam, QueryArray(ids)] ])
// Inserting
let age: Int? = 26
let user = User(id: 0, userName: "novi", age: age, status: .created, createdAt: Date())
let status = try conn.query("INSERT INTO `user` SET ?", [user]) as QueryStatus
let newId = status.insertedId
// Updating
let tableName = "user"
let defaultAge = 30
try conn.query("UPDATE ?? SET age = ? WHERE age is NULL;", [tableName, defaultAge])
Requirements
Install pkg-config .pc
file in cmysql or cmysql-mariadb.
# cmysql
$ brew tap novi/tap
$ brew install novi/tap/cmysql
# cmysql-mariadb
$ brew tap novi/tap
$ brew install novi/tap/cmysqlmariadb
libmariadbclient
$ sudo apt-get install libmariadbclient-dev
Installation
mysql-swift
to Package.swift
of your project.// swift-tools-version:5.2
import PackageDescription
let package = Package(
...,
dependencies: [
.package(url: "https://github.com/novi/mysql-swift.git", .upToNextMajor(from: "0.9.0"))
],
targets: [
.target(
name: "YourAppOrLibrary",
dependencies: [
// add a dependency
.product(name: "MySQL", package: "mysql-swift")
]
)
]
)
Usage
ConnectionPool.execute()
. It automatically get and release a connection.let option = Option(host: "your.mysql.host"...) // Define and create your option type
let pool = ConnectionPool(option: option) // Create a pool with the option
let rows: [User] = try pool.execute { conn in
// The connection `conn` is held in this block
try conn.query("SELECT * FROM users;") // And it returns result to outside execute block
}
let wholeStaus: QueryStatus = try pool.transaction { conn in
let status = try conn.query("INSERT INTO users SET ?;", [user]) as QueryStatus // Create a user
let userId = status.insertedId // the user's id
try conn.query("UPDATE info SET some_value = ? WHERE some_key = 'latest_user_id' ", [userId]) // Store user's id that we have created the above
}
wholeStaus.affectedRows == 1 // true
Author: novi
Source code: https://github.com/novi/mysql-swift
License: MIT license
#swift #mysql
1595905879
HTML to Markdown
MySQL is the all-time number one open source database in the world, and a staple in RDBMS space. DigitalOcean is quickly building its reputation as the developers cloud by providing an affordable, flexible and easy to use cloud platform for developers to work with. MySQL on DigitalOcean is a natural fit, but what’s the best way to deploy your cloud database? In this post, we are going to compare the top two providers, DigitalOcean Managed Databases for MySQL vs. ScaleGrid MySQL hosting on DigitalOcean.
At a glance – TLDR
ScaleGrid Blog - At a glance overview - 1st pointCompare Throughput
ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads. Read now
ScaleGrid Blog - At a glance overview - 2nd pointCompare Latency
On average, ScaleGrid achieves almost 30% lower latency over DigitalOcean for the same deployment configurations. Read now
ScaleGrid Blog - At a glance overview - 3rd pointCompare Pricing
ScaleGrid provides 30% more storage on average vs. DigitalOcean for MySQL at the same affordable price. Read now
MySQL DigitalOcean Performance Benchmark
In this benchmark, we compare equivalent plan sizes between ScaleGrid MySQL on DigitalOcean and DigitalOcean Managed Databases for MySQL. We are going to use a common, popular plan size using the below configurations for this performance benchmark:
Comparison Overview
ScaleGridDigitalOceanInstance TypeMedium: 4 vCPUsMedium: 4 vCPUsMySQL Version8.0.208.0.20RAM8GB8GBSSD140GB115GBDeployment TypeStandaloneStandaloneRegionSF03SF03SupportIncludedBusiness-level support included with account sizes over $500/monthMonthly Price$120$120
As you can see above, ScaleGrid and DigitalOcean offer the same plan configurations across this plan size, apart from SSD where ScaleGrid provides over 20% more storage for the same price.
To ensure the most accurate results in our performance tests, we run the benchmark four times for each comparison to find the average performance across throughput and latency over read-intensive workloads, balanced workloads, and write-intensive workloads.
Throughput
In this benchmark, we measure MySQL throughput in terms of queries per second (QPS) to measure our query efficiency. To quickly summarize the results, we display read-intensive, write-intensive and balanced workload averages below for 150 threads for ScaleGrid vs. DigitalOcean MySQL:
ScaleGrid MySQL vs DigitalOcean Managed Databases - Throughput Performance Graph
For the common 150 thread comparison, ScaleGrid averages almost 40% higher throughput over DigitalOcean for MySQL, with up to 46% higher throughput in write-intensive workloads.
#cloud #database #developer #digital ocean #mysql #performance #scalegrid #95th percentile latency #balanced workloads #developers cloud #digitalocean droplet #digitalocean managed databases #digitalocean performance #digitalocean pricing #higher throughput #latency benchmark #lower latency #mysql benchmark setup #mysql client threads #mysql configuration #mysql digitalocean #mysql latency #mysql on digitalocean #mysql throughput #performance benchmark #queries per second #read-intensive #scalegrid mysql #scalegrid vs. digitalocean #throughput benchmark #write-intensive
1661980680
This library is obsolete and not maintained. Use MySQLNIO instead.
MySQL client library for Swift. This is inspired by Node.js' mysql.
Codable
structs or classesNote: No asynchronous I/O support currently. It depends libmysqlclient.
// Declare a model
struct User: Codable, QueryParameter {
let id: Int
let userName: String
let age: Int?
let status: Status
let createdAt: Date
enum Status: String, Codable {
case created = "created"
case verified = "verified"
}
private enum CodingKeys: String, CodingKey {
case id
case userName = "user_name"
case age
case status = "status"
case createdAt = "created_at"
}
}
// Selecting
let nameParam = "some one"
let ids: [QueryParameter] = [1, 2, 3, 4, 5, 6]
let optionalInt: Int? = nil
let rows: [User] = try conn.query("SELECT id,user_name,status,status,created_at FROM `user` WHERE (age > ? OR age is ?) OR name = ? OR id IN (?)", [50, optionalInt, nameParam, QueryArray(ids)] ])
// Inserting
let age: Int? = 26
let user = User(id: 0, userName: "novi", age: age, status: .created, createdAt: Date())
let status = try conn.query("INSERT INTO `user` SET ?", [user]) as QueryStatus
let newId = status.insertedId
// Updating
let tableName = "user"
let defaultAge = 30
try conn.query("UPDATE ?? SET age = ? WHERE age is NULL;", [tableName, defaultAge])
Requirements
Install pkg-config .pc
file in cmysql or cmysql-mariadb.
# cmysql
$ brew tap novi/tap
$ brew install novi/tap/cmysql
# cmysql-mariadb
$ brew tap novi/tap
$ brew install novi/tap/cmysqlmariadb
libmariadbclient
$ sudo apt-get install libmariadbclient-dev
Installation
mysql-swift
to Package.swift
of your project.// swift-tools-version:5.2
import PackageDescription
let package = Package(
...,
dependencies: [
.package(url: "https://github.com/novi/mysql-swift.git", .upToNextMajor(from: "0.9.0"))
],
targets: [
.target(
name: "YourAppOrLibrary",
dependencies: [
// add a dependency
.product(name: "MySQL", package: "mysql-swift")
]
)
]
)
Usage
ConnectionPool.execute()
. It automatically get and release a connection.let option = Option(host: "your.mysql.host"...) // Define and create your option type
let pool = ConnectionPool(option: option) // Create a pool with the option
let rows: [User] = try pool.execute { conn in
// The connection `conn` is held in this block
try conn.query("SELECT * FROM users;") // And it returns result to outside execute block
}
let wholeStaus: QueryStatus = try pool.transaction { conn in
let status = try conn.query("INSERT INTO users SET ?;", [user]) as QueryStatus // Create a user
let userId = status.insertedId // the user's id
try conn.query("UPDATE info SET some_value = ? WHERE some_key = 'latest_user_id' ", [userId]) // Store user's id that we have created the above
}
wholeStaus.affectedRows == 1 // true
Author: novi
Source code: https://github.com/novi/mysql-swift
License: MIT license
#swift #mysql
1600430400
Swift is a fast and efficient general-purpose programming language that provides real-time feedback and can be seamlessly incorporated into existing Objective-C code. This is why developers are able to write safer, more reliable code while saving time. It aims to be the best language that can be used for various purposes ranging from systems programming to mobile as well as desktop apps and scaling up to cloud services.
Below here, we list down the 10 best online resources to learn Swift language.
(The list is in no particular order)
#developers corner #free online resources to learn swift language #learn swift #learn swift free #learn swift online free #resources to learn swift #swift language #swift programming
1609999986
A thoroughly researched list of top Swift developers with ratings & reviews to help find the best Swift development companies around the world.
#swift development service providers #best swift development companies #top swift development companies #swift development solutions #top swift developers #swift
1594193714
Want to create a native iOS application for your Startup?
Hire Dedicated Swift Developers for end-to-end services like development, migration, upgrade, testing, and support & maintenance. Trust HourlyDeveloper.io our Swift development team for iOS device apps that are high on performance and security.
Consult with experts:- https://bit.ly/2C5M6cz
#hire dedicated swift developers #swift developers #swift development company #swift development services #swift development #swift