GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - feather-framework/feather-database-mysql: MySQL/MariaDB driver implementation for the abstract Feather Database Swift API package.

BranchesTags
Open more actions menu

Latest commit

 

History

16 Commits
16 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
Sources
Sources
 
 
Tests
Tests
 
 
docker
docker
 
 
.dockerignore
.dockerignore
 
 
.gitignore
.gitignore
 
 
.swift-format
.swift-format
 
 
.swiftformatignore
.swiftformatignore
 
 
.swiftheaderignore
.swiftheaderignore
 
 
AGENTS.md
AGENTS.md
 
 
LICENSE
LICENSE
 
 
Makefile
Makefile
 
 
Package.resolved
Package.resolved
 
 
Package.swift
Package.swift
 
 
README.md
README.md
 
 
docker-compose.yaml
docker-compose.yaml
 
 

Repository files navigation

Feather Database MySQL

MySQL/MariaDB driver implementation for the abstract Feather Database Swift API package.

Release: 1.0.0-rc.3

Features

  • MySQL/MariaDB driver for Feather Database
  • Automatic query parameter escaping via Swift string interpolation.
  • Async sequence query results with Decodable row support.
  • Designed for modern Swift concurrency
  • DocC-based API Documentation
  • Unit tests and code coverage

Requirements

Swift 6.3+ Platforms: Linux, macOS, iOS, tvOS, watchOS, visionOS

  • Swift 6.3+
  • Platforms:
    • Linux
    • macOS 15+
    • iOS 18+
    • tvOS 18+
    • watchOS 11+
    • visionOS 2+

Installation

Add the dependency to your Package.swift:

.package(url: "https://github.com/feather-framework/feather-database-mysql", exact: "1.0.0-rc.3"),

Then add FeatherDatabaseMySQL to your target dependencies:

.product(name: "FeatherDatabaseMySQL", package: "feather-database-mysql"),

Usage

API documentation is available at the link below:

DocC API documentation

Here is a brief example:

import Logging
import MySQLNIO
import NIOCore
import NIOPosix
import NIOSSL
import FeatherDatabase
import FeatherDatabaseMySQL

try await withLogger(Logger(label: "example")) { _ in
    let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)

    let finalCertPath = URL(fileURLWithPath: "path/to/ca.pem")
    var tlsConfig = TLSConfiguration.makeClientConfiguration()
    let rootCert = try NIOSSLCertificate.fromPEMFile(finalCertPath)
    tlsConfig.trustRoots = .certificates(rootCert)
    tlsConfig.certificateVerification = .fullVerification

    let connection =
        try await MySQLConnection.connect(
            to: try SocketAddress(ipAddress: "127.0.0.1", port: 3306),
            username: "mariadb",
            database: "mariadb",
            password: "mariadb",
            tlsConfiguration: tlsConfig,
            logger: Logger.current,
            on: eventLoopGroup.next()
        )
        .get()

    let database = DatabaseClientMySQL(
        connection: connection
    )

    do {
        let result = try await database.withConnection { connection in
            try await connection.run(
                query: #"""
                    SELECT
                        VERSION() AS `version`
                    WHERE
                        1=\#(1);
                    """#
            )
        }
        
        for try await item in result {
            let version = try item.decode(column: "version", as: String.self)
            print(version)
        }

        try await connection.close().get()
        try await eventLoopGroup.shutdownGracefully()
    }
    catch {
        try await connection.close().get()
        try await eventLoopGroup.shutdownGracefully()

        throw error
    }
}

The package uses Logger.current from swift-log for database logging. Use withLogger to scope the logger for an operation; calls to Logger.current within that scope use the scoped logger.

Other database drivers

The following database client implementations are also available for use:

  • SQLite
  • Postgres

Development

  • Build: swift build
  • Test:
    • local: swift test
    • using Docker: make docker-test
  • Format: make format
  • Check: make check

Contributing

Pull requests are welcome. Please keep changes focused and include tests for new logic.

About

MySQL/MariaDB driver implementation for the abstract Feather Database Swift API package.

Topics

databasemariadbmysqlswift-6swift-concurrency

Resources

Readme
MIT license
Activity
Custom properties

Stars

1 star

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.