Learning SQLite for iOS
()
About this ebook
About This Book
- Implement Swift code using SQLite statements
- Learn the background to SQL and SQLite for mobile development, its statements, and command features through practical examples
- Extend the standard SQLite functionality and increase your software creation portfolio
Who This Book Is For
This book is intended for those who want to learn about SQLite and how to develop apps in Swift or HTML5 using SQLite. Whether you are an expert Objective-C programmer or new to this platform, you'll learn quickly, grasping the code in real-world apps to use Swift.
What You Will Learn
- Explore Swift's basic language statements
- Connect to SQLite and execute SQL statements
- Extend the SQLite language to create your own software extensions
- Use HTML5 with Phonegap on iOS
- Set up a Swift project using XCode with SQLite
- Administer SQLite databases in an easy and effective way
In Detail
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.
Style and approach
This book is a practical and comprehensive guide to developing applications using SQLite and iOS.
Related to Learning SQLite for iOS
Related ebooks
Modern Web Development with Deno: Develop Modern JavaScript and TypeScript Code with Svelte, React, and GraphQL (English Edition) Rating: 0 out of 5 stars0 ratingsCoding Languages: Angular With Typescript, Machine Learning With Python And React Javascript Rating: 0 out of 5 stars0 ratingsjQuery Mobile Web Development Essentials - Third Edition Rating: 0 out of 5 stars0 ratingsBuilding Web Applications with Flask Rating: 0 out of 5 stars0 ratingsLearning Angular for .NET Developers Rating: 0 out of 5 stars0 ratingsLearn SQL with MySQL: Retrieve and Manipulate Data Using SQL Commands with Ease Rating: 0 out of 5 stars0 ratingsApplication Development with Swift Rating: 0 out of 5 stars0 ratingsJavaScript Unlocked Rating: 5 out of 5 stars5/5Learning Windows Server Containers Rating: 0 out of 5 stars0 ratingsInstant HTML5 Geolocation How-To Rating: 0 out of 5 stars0 ratingsDeveloping Windows Store Apps with HTML5 and JavaScript Rating: 0 out of 5 stars0 ratingsAngular 2 Components Rating: 0 out of 5 stars0 ratingsLearning Swift Rating: 5 out of 5 stars5/5MariaDB Essentials Rating: 0 out of 5 stars0 ratingsASP.NET 3.5 Application Architecture and Design Rating: 0 out of 5 stars0 ratingsLearning Node.js for Mobile Application Development Rating: 0 out of 5 stars0 ratingsAjax in One Hour, For Beginners, Learn Coding Fast Rating: 0 out of 5 stars0 ratingsMultithreading with C# Cookbook - Second Edition Rating: 0 out of 5 stars0 ratingsCloning Internet Applications with Ruby Rating: 5 out of 5 stars5/5Windows PowerShell for .NET Developers - Second Edition Rating: 4 out of 5 stars4/5Multi-Tier Application Programming with PHP: Practical Guide for Architects and Programmers Rating: 0 out of 5 stars0 ratingsPHP Programming Solutions Rating: 0 out of 5 stars0 ratingsJavaScript JSON Cookbook Rating: 0 out of 5 stars0 ratingsNetwork Programming in .NET: With C# and Visual Basic .NET Rating: 3 out of 5 stars3/5iOS in Practice Rating: 0 out of 5 stars0 ratingsMastering Google App Engine Rating: 0 out of 5 stars0 ratingsPHP Ajax Cookbook Rating: 2 out of 5 stars2/5ASP.NET 4.0 in Practice Rating: 0 out of 5 stars0 ratingsLeveraging WMI Scripting: Using Windows Management Instrumentation to Solve Windows Management Problems Rating: 5 out of 5 stars5/5Programming with CodeIgniter MVC Rating: 0 out of 5 stars0 ratings
Enterprise Applications For You
Excel : The Ultimate Comprehensive Step-By-Step Guide to the Basics of Excel Programming: 1 Rating: 5 out of 5 stars5/5Excel Formulas and Functions 2020: Excel Academy, #1 Rating: 4 out of 5 stars4/5QuickBooks 2024 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsCreating Online Courses with ChatGPT | A Step-by-Step Guide with Prompt Templates Rating: 4 out of 5 stars4/5101 Ready-to-Use Excel Formulas Rating: 4 out of 5 stars4/5Create Income through Self-Publishing: An Author's Approach on Generating Wealth by Self-Publishing Rating: 5 out of 5 stars5/5ChatGPT Ultimate User Guide - How to Make Money Online Faster and More Precise Using AI Technology Rating: 0 out of 5 stars0 ratings50 Useful Excel Functions: Excel Essentials, #3 Rating: 5 out of 5 stars5/5Bitcoin For Dummies Rating: 4 out of 5 stars4/5Enterprise AI For Dummies Rating: 3 out of 5 stars3/5Learn Windows PowerShell in a Month of Lunches Rating: 0 out of 5 stars0 ratingsScrivener For Dummies Rating: 4 out of 5 stars4/5Mastering QuickBooks 2020: The ultimate guide to bookkeeping and QuickBooks Online Rating: 0 out of 5 stars0 ratingsQuickBooks 2023 All-in-One For Dummies Rating: 0 out of 5 stars0 ratingsSystems Thinking: Managing Chaos and Complexity: A Platform for Designing Business Architecture Rating: 4 out of 5 stars4/5Access 2019 For Dummies Rating: 0 out of 5 stars0 ratingsQuickBooks 2021 For Dummies Rating: 0 out of 5 stars0 ratingsSharePoint 2016 For Dummies Rating: 5 out of 5 stars5/5Notion for Beginners: Notion for Work, Play, and Productivity Rating: 4 out of 5 stars4/5Excel Tips and Tricks Rating: 0 out of 5 stars0 ratingsPowerShell for SQL Server Essentials Rating: 0 out of 5 stars0 ratingsExcel 2016 For Dummies Rating: 4 out of 5 stars4/5Essential Office 365 Third Edition: The Illustrated Guide to Using Microsoft Office Rating: 3 out of 5 stars3/5The Ridiculously Simple Guide to Google Docs: A Practical Guide to Cloud-Based Word Processing Rating: 0 out of 5 stars0 ratingsExcel 2019 Bible Rating: 4 out of 5 stars4/5
Reviews for Learning SQLite for iOS
0 ratings0 reviews
Book preview
Learning SQLite for iOS - (Hons) Gene Da Rocha MSc BSc
Table of Contents
Learning SQLite for iOS
Credits
About the Author
About the Reviewer
www.PacktPub.com
eBooks, discount offers, and more
Why subscribe?
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Introduction to SQL and SQLite
About SQL
Where does SQLite stand in today's industry?
iOS with SQLite
Embedded databases
The architecture of the SQLite database
Features
The advantages of using SQLite
Working with SQLite
The examples of using SQLite with iOS
Summary
2. Database Design Concepts
Database essentials
Reasons for using SQLite
Database connections
Preparing queries
Parameterized SQL
Error handling
Queries within the db.exec statement
SQL injection attacks
Creating user-defined functions
Transactions and locks
Transactions – reading/writing
Designing for SQLite
Summary
3. Administering the Database
Creating a database
Creating a table
Inserting data
Selecting data
Creating an index
Exporting data
Viewing database schema data
Index data
Schema data
Backing up the database
Database tools
Database file information
Summary
4. Essentials of SQL
Transactions
Query plan
SQL basics
Insert with a subselect clause
Update with a subselect clause
Select with a subselect clause
Data integrity
Default values
Constraint checking
Foreign keys
Updating Views
Index use
Triggers
Synchronous writes
Database locking and deadlocks
FMDB SQLite wrapper
Database creation and opening
SQL in iOS
Summary
5. Exposing the C API
SQLite C components' functionality
sqlite3_open()
sqlite3_prepare()
sqlite3_step()
sqlite3_column()
sqlite3_finalize()
sqlite3_close()
Using the C API with the open database statement
Using Swift with the open database statement
load_extension()
sqlite3_exec()
sqlite3_config()
The prepare statement
Summary
6. Using Swift with iOS and SQLite
Basic requirements
Starting an Xcode Project with Swift
Using the SQLite 3 Library
Using FMDB
Summary
7. iOS Development with PhoneGap and HTML5
HTML5 and PhoneGap development
An HTML5 framework
Hybrid applications
An Xcode project with PhoneGap, HTML5, and Swift
Summary
8. More Features and Advances in SQLite
PhoneGap plugins
Extensions to the C API
Write Ahead Logging with SQLite
The B-tree usage with SQLite
Creating a simple Swift
Summary
Index
Learning SQLite for iOS
Learning SQLite for iOS
Copyright © 2016 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: March 2016
Production reference: 1180316
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-78528-897-5
www.packtpub.com
Credits
Author
Gene Da Rocha, MSc, BSc (Hons)
Reviewers
Alvaro Franco
Ting Xiao
Acquisition Editors
Larissa Pinto
Subho Gupta
Content Development Editor
Rashmi Suvarna
Technical Editor
Anushree Arun Tendulkar
Copy Editors
Charlotte Carneiro
Yesha Gangani
Ameesha Green
Project Coordinator
Judie Jose
Proofreader
Safis Editing
Indexer
Tejal Daruwale Soni
Graphics
Abhinash Sahu
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
Gene Da Rocha, MSc, BSc (Hons) in mobile and computer science is an experienced IT professional with over 25 years in the IT industry. He has worked for a variety of companies nationally and internationally, in different industries including corporate, start-up, pharmaceutical, finance, banking, and the NHS.
Gene is also the owner and founder of a mobile solutions company, Voxstar (www.voxstar.com), based in London and Buckinghamshire. He comes from a programming and development background, and has worked with database technology, iOS, Android, Windows mobile, and a variety of other technologies.
He has been helping and advising, programming, and recently testing software for a number of companies such as DigitasLBI, Oxfam, News UK, QAWorks, Reuters, and the Association for Project Management, among many others.
About the Reviewer
Alvaro Franco is an iOS engineer and web developer. He has contributed to the iOS and OS X open source community. He has also been a part of Aluana, building Mindrop, and companies such as Mozilla, where he contributed to delivering Firefox for iOS. Alvaro is also a motorsport fan and guitarist.
Ting Xiao, is a frontend developer focusing on how to make things good on the webpage; she is also working on the development of a mobile app simultaneously. She is interested in any brain technology. According to Ting, thanks to the technology, we can know this world much better.
www.PacktPub.com
eBooks, discount offers, and more
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks.
https://www2.packtpub.com/books/subscription/packtlib
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library. Here, you can search, access, and read Packt's entire library of books.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Preface
SQLite is still a widely used database for mobile applications on smartphones and tablets. For those with SQL experience, it will be easier to understand and learn what it has to offer and the applications it can be used for. SQLite was released in 2000 has grown to be a well-used database for mobile device development.
Mr. D. Richard Hipp developed it on a battleship while he was at a company called General Dynamics. Initially used as storage, it was then developed using a B-tree implementation, which enhanced it and enabled the storage of rows and transactions.
This book gives you the opportunity to learn elements of SQLite, the mobile database; its interaction with the MAC operating system, Xcode; and the developer IDE for Apple apps and PhoneGap, which enables HTML5. It outlines how easy it is to work with SQLite.
What this book covers
Chapter 1, Introduction to SQL and SQLite, introduces you to the background of Structured Query Language (SQL) and the mobile database SQLite.
Chapter 2, Database Design Concepts, talks about the database concepts in SQLite.
Chapter 3, Administering the Database, introduces you to administering the SQLite database and makes you aware of the different components of this relational database.
Chapter 4, Essentials of SQL, this chapter talks about the essentials of SQL. It will outline the major possibilities with SQL and how it can be used properly on SQLite. This is essential so that you understand how SQL can be used and its limitations and advantages.
Chapter 5, Exposing the C API, deals with the C API and how you can extend its application use and produce the applications that you require using code.
Chapter 6, Using Swift with iOS and SQLite, looks at using the new programming language from Apple, Swift, with SQLite.
Chapter 7, iOS Development with PhoneGap and HTML5, looks at how to use Xcode with PhoneGap to integrate and compile with source code, including HTML5.
Chapter 8, More Features and Advances in SQLite, deals with how SQLite has changed in recent years, how it has advanced to be integrated into a variety of existing technologies, and how its simple easy-to-use formula has guaranteed its popularity with others.
What you need for this book
In this book, the software required will be the following:
Mac Operating System:
OS X 10.9 or later
Software:
Xcode IDE software development environment (version 7.0-7.1.1+) with Swift support
Latest version of PhoneGap from PhoneGap.com
Latest version of Node.js from https://nodejs.org/en/
Who this book is for
This book is intended for those who want to learn about the most powerful and flexible mobile database for developing apps in Swift or Objective-C the right way. If you are an expert Objective-C programmer or new to this platform, you'll learn quickly, grasping the code of real-world apps to use Swift effectively.
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: This language has a variety of statements but most would recognize the INSERT, SELECT, UPDATE and DELETE statements.
A block of code is set as follows:
SELECT parameter1, STTDEV(parameter2)
FROM Table1 Group by parameter1
HAVING parameter1 > MAX(parameter3)
Any command-line input or output is written as follows:
$ sqlite3 testdatabase.db
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: Then at the bottom of the page, within the Linked Frameworks and Libraries, click on the + and a modal window will appear.
Note
Warnings or important notes appear in a box like this.
Tip
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.
To send us general feedback, simply e-mail <feedback@packtpub.com>, and mention the book's title in the subject of your message.
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.
Customer support
Now that you are the proud