Skip to content

LordDarkula/EasyQL

Repository files navigation

EasyQL

Build Status Version License Platform Twitter

Introduction

A quick and convenient way to create and manage local sqlite3 databases. Databases can be created with a single line of code. Data can be get and set without creating queries. Queries can also be passed in as a string.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 0.39.0+ is required to build EasyQL

To install it, simply add the following line to your Podfile:

pod "EasyQL"

Author

Aubhro, aubhrosengupta@gmail.com

License

EasyQL is available under the MIT license. See the LICENSE file for more info.

Usage

First, import EasyQL

#import <EasyQL.h>

Create a table

// Table name stored in myTableName
NSString *name = @"myTableName";

// Columns named "first" and "second"
NSArray *columns = @[@"first", @"second"];

[EasyQL createDB:name :columns];

Add data to the table

NSMutableArray *data = [[NSMutableArray alloc] init];
[data insertObject:@[@"one", @"two"] atIndex:0];
[data insertObject:@[@"three", @"four"] atIndex:1];

[EasyQL setData:name :columns :data];

To get the data

NSMutableArray *data = [EasyQL getData:name];

data would have the following structure

@[ @[ @"one", @"two"],
   @[ @"three", @"four"]]

To use queries with EasyQL

// This particular query deletes everything in the query, but any query should work
NSString *query = [NSString stringWithFormat:@"DELETE FROM %@", name];
[SQL applyQuery:name :query];

Thats it for now. I will keep adding functionality as time goes on.