All Projects → PerfectlySoft → Perfect Sqlite

PerfectlySoft / Perfect Sqlite

Licence: apache-2.0
A stand-alone Swift wrapper around the SQLite 3 client library.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Perfect Sqlite

Fluent Sqlite Driver
Fluent driver for SQLite
Stars: ✭ 51 (+21.43%)
Mutual labels:  database, sqlite, sqlite3, server-side-swift
D2sqlite3
A small wrapper around SQLite for the D programming language
Stars: ✭ 67 (+59.52%)
Mutual labels:  database, sqlite, sqlite3
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+2916.67%)
Mutual labels:  database, sqlite, sqlite3
Esp32 arduino sqlite3 lib
Sqlite3 Arduino library for ESP32
Stars: ✭ 167 (+297.62%)
Mutual labels:  database, sqlite, sqlite3
Android dbinspector
Android library for viewing and sharing in app databases.
Stars: ✭ 881 (+1997.62%)
Mutual labels:  database, sqlite, sqlite3
Choochoo
Training Diary
Stars: ✭ 186 (+342.86%)
Mutual labels:  database, sqlite, sqlite3
Sqlite3 Encryption
The easiest way to build SQLite3 with encryption support on Windows. Compilation of DLL, SLL or shell is now a matter of minutes
Stars: ✭ 102 (+142.86%)
Mutual labels:  database, sqlite, sqlite3
Squeal
A Swift wrapper for SQLite databases
Stars: ✭ 303 (+621.43%)
Mutual labels:  database, sqlite, sqlite3
Better Sqlite3
The fastest and simplest library for SQLite3 in Node.js.
Stars: ✭ 2,778 (+6514.29%)
Mutual labels:  database, sqlite, sqlite3
Pydbgen
Random dataframe and database table generator
Stars: ✭ 191 (+354.76%)
Mutual labels:  database, sqlite, sqlite3
Mikro Orm
TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.
Stars: ✭ 3,874 (+9123.81%)
Mutual labels:  database, sqlite, sqlite3
Denodb
MySQL, SQLite, MariaDB, PostgreSQL and MongoDB ORM for Deno
Stars: ✭ 498 (+1085.71%)
Mutual labels:  database, sqlite, sqlite3
Easydb
Easy-to-use PDO wrapper for PHP projects.
Stars: ✭ 624 (+1385.71%)
Mutual labels:  database, sqlite
Beekeeper Studio
Modern and easy to use SQL client for MySQL, Postgres, SQLite, SQL Server, and more. Linux, MacOS, and Windows.
Stars: ✭ 8,053 (+19073.81%)
Mutual labels:  database, sqlite
Sqlite Global Tool
SQLite .NET Core CLI tool that allows the user to manually enter and execute SQL statements with or without showing query result.
Stars: ✭ 37 (-11.9%)
Mutual labels:  sqlite, sqlite3
Database rewinder
minimalist's tiny and ultra-fast database cleaner
Stars: ✭ 685 (+1530.95%)
Mutual labels:  database, sqlite3
Typeorm
ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.
Stars: ✭ 26,559 (+63135.71%)
Mutual labels:  database, sqlite
Node Sqlite
SQLite client for Node.js applications with SQL-based migrations API written in Typescript
Stars: ✭ 642 (+1428.57%)
Mutual labels:  database, sqlite
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+1607.14%)
Mutual labels:  database, sqlite
Migrate
Database migrations. CLI and Golang library.
Stars: ✭ 7,712 (+18261.9%)
Mutual labels:  database, sqlite

Perfect - SQLite Connector

Get Involed with Perfect!

Star Perfect On Github Stack Overflow Follow Perfect on Twitter Join the Perfect Slack

Swift 4.0 Platforms OS X | Linux License Apache PerfectlySoft Twitter Slack Status

This project provides a Swift wrapper around the SQLite 3 library.

This package builds with Swift Package Manager and is part of the Perfect project. It was written to be stand-alone and so does not require PerfectLib or any other components.

Ensure you have installed and activated the latest Swift 4.0 tool chain.

To learn more, you can read the full documentation guide here

Linux Build Notes

Ensure that you have installed sqlite3.

sudo apt-get install sqlite3

Building

Add this project as a dependency in your Package.swift file.

.Package(url: "https://github.com/PerfectlySoft/Perfect-SQLite.git", majorVersion: 3)

Edge Case

If you encounter error like such sqlite3.h file not found during $ swift build, one solution is to install the sqlite3-dev i.e. $ sudo apt-get install libsqlite3-dev

Usage Example

Let’s assume you’d like to host a blog in Swift. First we need tables. Assuming you’ve created an SQLite file ./db/database, we simply need to connect and add the tables.

let dbPath = "./db/database"

do {
	let sqlite = try SQLite(dbPath)
	defer {  
		sqlite.close()
	}

	try sqlite.execute(statement: "CREATE TABLE IF NOT EXISTS posts (id INTEGER PRIMARY KEY NOT NULL, post_title TEXT NOT NULL, post_content TEXT NOT NULL, featured_image_uri TEXT NOT NULL)")
} catch {
	print("Failure creating database tables") //Handle Errors
}

Next, we would need to add some content.

let dbPath = "./db/database"
let postTitle = "Test Title"
let postContent = "Lorem ipsum dolor sit amet…"

do {
   let sqlite = try SQLite(dbPath)
   defer {
     sqlite.close()
   }

   try sqlite.execute(statement: "INSERT INTO posts (post_title, post_content) VALUES (:1,:2)") {
     (stmt:SQLiteStmt) -> () in

     try stmt.bind(position: 1, postTitle)
     try stmt.bind(position: 2, postContent)
   }
 } catch {
		//Handle Errors
 }

Finally, we retrieve posts and post titles from an SQLite database full of blog content. Each id, post, and title is appended to a dictionary for use elsewhere.

let dbPath = "./db/database"
var contentDict = [String: Any]()

do {
	let sqlite = try SQLite(dbPath)
		defer {
			sqlite.close() // This makes sure we close our connection.
		}
	
	let demoStatement = "SELECT post_title, post_content FROM posts ORDER BY id DESC LIMIT :1"
	
	try sqlite.forEachRow(statement: demoStatement, doBindings: {
		
		(statement: SQLiteStmt) -> () in
		
		let bindValue = 5
		try statement.bind(position: 1, bindValue)
		
	}) {(statement: SQLiteStmt, i:Int) -> () in

        self.contentDict.append([
                "id": statement.columnText(position: 0),
                "second_field": statement.columnText(position: 1),
                "third_field": statement.columnText(position: 2)
            ])
  }
	
} catch {
	//Handle Errors
}

Further Information

For more information on the Perfect project, please visit perfect.org.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].