mysql-swift
MySQL client library for Swift.
This is inspired by Node.js' mysql.
- Based on libmysqlclient
- Raw SQL query
- Simple query formatting and escaping (same as Node's)
- Mapping queried results to
Codable
structs or classes
Note: No asynchronous I/O support currently. It depends libmysqlclient.
Requirements
- Swift 5.0 or later
- MariaDB or MySQL Connector/C (libmysqlclient) 2.2.3 or later
macOS
Install pkg-config .pc
file in cmysql or cmysql-mariadb.
Ubuntu
- Install
libmariadbclient
- Follow Setting up MariaDB Repositories and set up your repository.
Installation
Swift Package Manager
- Add
mysql-swift
toPackage.swift
of your project.
Usage
Connection & Querying
- Create a pool with options (hostname, port, password,...).
- Use
ConnectionPool.execute()
. It automatically get and release a connection.
Transaction
License
MIT