Proof of Concept Project for a SQL Persistence Layer for IBM's Kitura Swift Web Server



Kitura SQL Proof of Concept


  • Show an understanding of the Swift Language
  • Familiarize myself with the LinuxSwift/Kitura ecosystem
  • Provide something potentially useful to the community


  1. IBM would like to expand Kitura adoption and Mindshare
  2. App developers are a target market for the Kitura ecosystem
  3. App developers are used to writing apps against Rails-style REST interfaces
  4. There doesn't seem to be a SQL interface for Kitura persistence
  5. Creating a SQL-based easily-configured persistence option for Kitura would be useful to app developers (and hopefully other developers as well)

User-Facing Features

  • Drop-in SQL persistence mechanism
  • Basic REST Object CRUD functionality
  • Dynamically-Altered schema, driven by PUT and POST operations
  • Switch to turn dynamic-updating on or off
  • WebService runs on OS X or Linux (although numbers are returned as Strings under Linux for now to avoid a JSON encoding issue)

Software Design Features

  • Kitura-SQLite module has XCTest Integration tests that run under OS X and Linux
  • Developers can build on this functionality by defining their own routes
  • Protocol abstracted to allow different SQL library implementations with minimal changes to the web service
    • Currently with only SQLite implemented as a back-end
    • Hopefully & eventually this can expand


  • Kitura-SQL-PoC Proof-of-Concept Persistence Layer for Kitura (this repository)
  • Kitura-SQLProtocol - An abstraction layer to sit in between Kitura and various SQL library implementations
  • Kitura-SQLite a SQLite-based implementation of the KituraSQLProtocol
  • CSQLite - A very simple Swift wrapper around libsqlite3 (primarily a and Package.swift file)

Still Lacking

  • Need to write code to create and query join-tables dynamically
  • Need to define default routes for queries other than All and by ID
  • Fix issue with JSON encoding failing for Int/Real dictionary values
  • Add support for BLOB/DATE types
  • Need to audit for security, and sanitize the JSON input
  • Move Logging to be consistent with other packages
  • Need to tune for performance
    • Currently the sqlite file is being closed at the end of each query for safety, which won't scale