{"id":18936385,"url":"https://github.com/vaporexampleslab/vapor-til-sqlite","last_synced_at":"2026-03-21T03:30:14.893Z","repository":{"id":133115025,"uuid":"138093177","full_name":"VaporExamplesLab/vapor-til-sqlite","owner":"VaporExamplesLab","description":"An sqlite variant of raywenderlich/vapor-til. Uses Vapor 3 \u0026 Swift 4","archived":false,"fork":false,"pushed_at":"2018-12-07T01:01:49.000Z","size":44,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-31T21:26:11.813Z","etag":null,"topics":["vapor","vapor-3","vapor-example"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/VaporExamplesLab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-20T22:38:49.000Z","updated_at":"2023-11-11T23:20:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"601a99f6-3edc-4fdd-a8ee-aca91aa3e62a","html_url":"https://github.com/VaporExamplesLab/vapor-til-sqlite","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2Fvapor-til-sqlite","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2Fvapor-til-sqlite/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2Fvapor-til-sqlite/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/VaporExamplesLab%2Fvapor-til-sqlite/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/VaporExamplesLab","download_url":"https://codeload.github.com/VaporExamplesLab/vapor-til-sqlite/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239937702,"owners_count":19721482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["vapor","vapor-3","vapor-example"],"created_at":"2024-11-08T12:07:14.623Z","updated_at":"2026-03-21T03:30:14.866Z","avatar_url":"https://github.com/VaporExamplesLab.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n# Vapor TIL SQLite\n\n\u003ca id=\"toc\"\u003e\u003c/a\u003e\n[Overview](#Overview) |\n[PostgreSQL → SQLite](#PostgreSQLToSQLite) |\n[Resources](#Resources)\n\n## Overview \u003ca id=\"Overview\"\u003e[▴](#toc)\u003c/a\u003e\n\nThe [vapor-til-sqlite]() is based on [raywenderlich/vapor-til](https://github.com/raywenderlich/vapor-til). Some key aspects of `vapor-til-sqlite` are:\n\n* SQLite is used instead of PostgreSQL. \n* SQLite pivot `id` type is `Int` instead of `UUID`.\n* TBD: Tests pass on Linux 16.04?\n* Swift script to populate database.\n* `Imperial` package and related files for OAth login are commented out.\n* Demo user: `admin`:`password`\n\n## PostgreSQL → SQLite Conversion \u003ca id=\"PostgreSQLToSQLite\"\u003e[▴](#toc)\u003c/a\u003e\n\nDirect find \u0026 replace. \n\n| `PostgreSQL`               | `SQLite`               |\n|----------------------------|------------------------|\n| `FluentPostgreSQL`         | `FluentSQLite`         |\n| `FluentPostgreSQLProvider` | `FluentSQLiteProvider` |\n| `PostgreSQLModel`          | `SQLiteModel`          |\n| `PostgreSQLUUIDModel`      | `SQLiteUUIDModel`      |\n| `PostgreSQLConnection`     | `SQLiteConnection`     |\n| `.psql`                    | `.sqlite`              |\n\nRewritten sections.\n\n| `PostgreSQL`               | `SQLite`               |\n|----------------------------|------------------------|\n| `PostgreSQLDatabase`       | `SQLiteDatabase`       |\n| `PostgreSQLDatabaseConfig` | `SQLiteStorage`        |\n| `PostgreSQLUUIDPivot`      | `SQLitePivot`          |\n\n\n`configure.swift` PostgreSQLDatabaseConfig, PostgreSQLDatabase\n\n``` swift\n// Configure a database\nvar databases = DatabasesConfig()\nlet databaseConfig: PostgreSQLDatabaseConfig\nif let url = Environment.get(\"DATABASE_URL\") {\n  databaseConfig = try PostgreSQLDatabaseConfig(url: url)\n} else {\n  let databaseName: String\n  let databasePort: Int\n  if (env == .testing) {\n    databaseName = \"vapor-test\"\n    if let testPort = Environment.get(\"DATABASE_PORT\") {\n      databasePort = Int(testPort) ?? 5433\n    } else {\n      databasePort = 5433\n    }\n  }\n  else {\n    databaseName = Environment.get(\"DATABASE_DB\") ?? \"vapor\"\n    databasePort = 5432\n  }\n\n  let hostname = Environment.get(\"DATABASE_HOSTNAME\") ?? \"localhost\"\n  let username = Environment.get(\"DATABASE_USER\") ?? \"vapor\"\n  let password = Environment.get(\"DATABASE_PASSWORD\") ?? \"password\"\n  databaseConfig = PostgreSQLDatabaseConfig(hostname: hostname, port: databasePort, username: username, database: databaseName, password: password)\n}\nlet database = PostgreSQLDatabase(config: databaseConfig)\ndatabases.add(database: database, as: .psql)\nservices.register(databases)\n```\n\n`configure.swift` SQLiteStorage, SQLiteDatabase\n\n``` swift\n// Configure a database\nvar databases = DatabasesConfig()\nvar storage: SQLiteStorage!  \nswitch env {\ncase .development:\n    // default: \"/tmp/db.sqlite\"\n    let sqlitePath = \"/Volumes/gMediaHD/VaporProjects/workspace/databases/vapor-til-sqlite.sqlite\"\n    storage = .file(path: sqlitePath)\ncase .testing:\n    // \"/tmp/_swift-tmp.sqlite\"\n    storage = .memory\ncase .production:\n    storage = .memory\ndefault:\n    // includes custom\n    storage = .memory\n}\nlet sqliteDb = try SQLiteDatabase(storage:  storage)\ndatabases.add(database: sqliteDb, as: .sqlite) \nservices.register(databases)\n```\n\n## Notes\n\n**`vapor-til-sqlite`** has not yet been tested on Linux.\n\n## Resources \u003ca id=\"Resources\"\u003e[▴](#toc)\u003c/a\u003e\n\n* [GitHub/raywenderlich: vapor-til ⇗](https://github.com/raywenderlich/vapor-til)\n* [Ray Wenderlich Video Courses: Server Side Swift with Vapor ⇗](https://videos.raywenderlich.com/courses/115-server-side-swift-with-vapor/lessons/1)\n* [Vapor: documentation ⇗](https://docs.vapor.codes/3.0/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaporexampleslab%2Fvapor-til-sqlite","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvaporexampleslab%2Fvapor-til-sqlite","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvaporexampleslab%2Fvapor-til-sqlite/lists"}