Swiftpack.co - Oops-AB/FrontbaseNIO as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Oops-AB.
Oops-AB/FrontbaseNIO 1.3
Swift wrapper for Frontbase database
⭐️ 0
🕓 3 weeks ago
.package(url: "https://github.com/Oops-AB/FrontbaseNIO.git", from: "1.3")

Frontbase for Vapor


This package is Swift wrapper for FBCAccess – the official C library for Frontbase –, which must be installed separately before using it in Swift projects.

Note: the database itself does not need to be running, only the header and library files matter.

Install Frontbase

Download an appropriate installer from the Frontbase download page.

Setup Frontbase for pkgConfig

Swift requires a pkgConfig configuration to find the header and library files.

Run the provided setupFBCAccess.sh script to install the required configuration file. It will sudo, so use an account that's in sudoers.

Using Frontbase

This section outlines how to import the Frontbase package for use in a Vapor project.

Include the Frontbase package in your project's Package.swift file.

import PackageDescription

let package = Package(
    name: "Project",
    dependencies: [
        .package (url: "https://github.com/Oops-AB/FrontbaseNIO.git", from: "1.0.0"),
    targets: [ ... ]

The FrontbaseNIO package adds low level asynchronous Frontbase access to your project.


Setting up the Database

import FrontbaseNIO

	// Configure a Frontbase database
    let connection = try FrontbaseConnection.open (storage: .named (name: "Universe",
                                                                    hostName: "localhost",
                                                                    username: "_system",
                                                                    password: "secret"),
                                                   threadPool: threadPool,
                                                   on: eventLoop)

Executing SQL

    let galaxyID = 1.frontbaseData!

    connection.query ("SELECT id, name FROM Planet WHERE galaxyID = ? ORDER BY name",
        .map { rows in
            rows.forEach { row in
                let id = row.firstValue (forColumn: "id")
                let name = row.firstValue (forColumn: "name")
                print ("Planet \(id?.description ?? "-"): \(name?.description ?? "-")")


The Frontbase connection will be setup to use the UTC time zone, for optimal interoperability with the Date type. If you, for some reason, generate timestamp literals in raw SQL, make sure that those are expresssed in the UTC time zone.


Stars: 0
Last commit: 3 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics