---
title: "iOS : SQLite Database is a Software Library"  
description: "Previously: we learn about SQLite and standard SQLite commands : iOS : SQLite engine  SQLite Database Engine is a software library that provides a Rel"  
author: "Tarun Kumar"  
published: 2015-08-19  
updated: 2018-02-27  
canonical: https://www.mindstick.com/blog/10940/ios-sqlite-database-is-a-software-library  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# iOS : SQLite Database is a Software Library

**Previously: we learn about** SQLite and standard SQLite commands : [iOS :](https://www.mindstick.com/Blog/Edit/10934#.VdVx2pcrjIU) [SQLite engine](https://www.mindstick.com/Blog/Edit/10934#.VdVx2pcrjIU)

\

**SQLite** Database Engine is a software library that provides a Relational [Database Management](https://www.mindstick.com/forum/34816/what-is-mapping-constraints-in-database-management-system) System similar to MySQL or Oracle. It is ‘Server-Less’, ‘Self-Contained’ with ‘Zero Configuration’ and uses ‘Transactional SQL’. These features make it a perfect candidate for [mobile devices](https://yourviews.mindstick.com/view/85524/influence-of-mobile-devices-on-travel-and-tourism-experiences). In IOS SQLite is easily embedded with the application, as it is simply a [file format](https://www.mindstick.com/forum/382/how-to-import-and-export-data-in-sql-server-from-different-file-format). It replaces the ‘plist’ implementation for storing and handling the [complex data](https://www.mindstick.com/forum/160789/how-to-handle-complex-data-binding-scenarios-in-knockout-js) in IOS.

## How to use SQLite in iOS?

The ‘libsqlite3.dylib’ library in framework section is required to be added in an application, which is a C++ wrapper that provides the API to the SQLite commands. To use the SQLite commands, it is mandatory to import the ‘sqlite3’ header file.

## IOS SQLite Create Database and Table

Creating [SQLite Database](https://www.mindstick.com/articles/1554/crud-operation-in-asp-dot-net-using-sqlite-database) is similar to creating a text file. In iOS, a path of document directory is used to save the [database file](https://www.mindstick.com/forum/159377/how-to-add-edit-retrieve-data-using-local-database-file-in-microsoft-visual-studio-2012) in application because only that folder is accessible by iOS application for user data.

To execute any query in SQLite database, first, a database is opened for querying, for this purpose a ‘**sqlite3_open**’ method is used with the path of a database and ‘sqlite3’ object as arguments. On successful execution, it returns the constant ‘**SQLITE_OK**’ equals to zero.

Finally, to create a table in database an iOS SQLite API method ‘**sqlite3_exec**’ is used with the open sqlite3 object, a SQL query of creating the table, [callback function](https://www.mindstick.com/forum/157808/what-is-a-callback-function-and-how-is-it-used-in-javascript), the first argument to the callback function and [error message](https://www.mindstick.com/forum/23174/error-message-the-page-you-are-requesting-cannot-be-served-because-of-the-extension-configuration) container as arguments. On successful execution, it returns ‘SQLITE_OK’ or in case of failed execution, SQL error and missing database an ‘SQLITE_ERROR’ equal to ‘1’.

---

Original Source: https://www.mindstick.com/blog/10940/ios-sqlite-database-is-a-software-library

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
