Book Image

Learning SQLite for iOS

By : Gene Da Rocha
Book Image

Learning SQLite for iOS

By: Gene Da Rocha

Overview of this book

The ability to use SQLite with iOS provides a great opportunity to build amazing apps. Apple's iOS SDK provides native support for SQLite databases. This combination offers the potential to create powerful, data-persistent applications. This book starts with the architecture of SQLite database and introduces you to concepts in SQL . You will find yourself equipped to design your own database system, administer it, and maintain it. Further, you will learn how to operate your SQLite databases smoothly using SQL commands. You will be able to extend the functionality of SQLite by using its vast arsenal of C API calls to build some interesting, exciting, new, and intelligent data-driven applications. Understand how Xcode, HTML5, and Phonegap can be used to build a cross-platform modern app which can benefit from all these technologies - all through creating a complete, customizable application skeleton that you can build on for your own apps.
Table of Contents (15 chapters)
Learning SQLite for iOS
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Database connections


The sqlite3_open() C API function is used to open a connection to the database and is held in a single operating system file. This function actually opens the file, and thus, a secure connection is made that is not shared. If the memory option is used, then the database will be created in random access memory (RAM), once the connection is established. The database will then be removed and deleted from RAM when the connection closed.

SQLite will attempt to open an existing database, and if an entered database name does not exist, then it will assume that the programmer wants to create one. SQLite is clever if you want to create a database and then close it without any operation, such as creating a table: it will not actually spend resources creating the database, only an empty file will exist:

sqlite3 aFile.db "create table aTable(field1 int); drop table aTable;"

The preceding statement will create the required default file with a table and will then drop/delete it, leaving...