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

Backing up the database


There are a couple of ways to back up your SQLite database. To make it portable, use the .dump statement as part of the CLP, which can export the entire database and scripts to the filesystem. An example can be seen as follows:

The preceding statement shows how to invoke SQLite with a database name and pipe the output to a file called temp.sql.

Following is another way to invoke SQLite and then perform a backup interactively.

User can directly import the data, by the following set of commands:

The following command will open SQLite and the temp.db database, and import the temp.sql file to it. Within the temp.sql file, there will be scripts to read the source files and import data back to database (existing or new version):

There is another way, just copy the temp.db file to a version called temp.backup, but the aforementioned methods are much better and portable, and there may be binary compatibility issues since SQLite does not have a great reputation for backward compatibility...