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.
Download an appropriate installer from the Frontbase download page.
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
.
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.
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)
.wait()
)
let galaxyID = 1.frontbaseData!
connection.query ("SELECT id, name FROM Planet WHERE galaxyID = ? ORDER BY name",
[galaxyID])
.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 ?? "-")")
}
}
.wait()
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.
link |
Stars: 0 |
Last commit: 1 week ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics