Latest 1.0.2
Homepage https://github.com/AlvaroFranco/AFSQLManager
License MIT
Authors

Build Status
[alt text]()
[alt text]()
[alt text]()

SQL and SQLite database manage on iOS made easy. Create, open, rename and delete databases with AFSQLManager, a block-driven iOS SQL and SQLite manager class. Perform queries never has been that easy!

alt text

Installation

AFSQLManager is available on CocoaPods so you can get it by adding this line to your Podfile:

pod 'AFSQLManager', '~> 1.0'

If you don’t use CocoaPods, you will have to import these files into your project:

AFSQLManager.h
AFSQLManager.m

Also, make sure to import libsqlite3.dylib library on the Frameworks section!

Usage

First of all, make sure that you have imported the main class into the class where you are going to play audio.

#import "AFSQLManager.h"

Managing the databases files

Create a brand new database

To create a new file, use the method -createDatabaseWithName:openImmediately:withStatusBlock:. Let’s say you need to create a database called nyancat.sqlite:

[[AFSQLManager sharedManager]createDatabaseWithName:@"nyancat.sqlite" openInmediately:YES withStatusBlock:^(BOOL success, NSError *error) {

    if (success) {
        // Yeah, database created successfully
    } else {
        NSLog(@"%@",error);
    }
}];

You can also choose if the database should be opened once it’s created.

Open and closing an existing database

If you already have your database imported into your project, start using that database is as simple as use -openLocalDatabaseWithName:andStatusBlock:

[[AFSQLManager sharedManager]openLocalDatabaseWithName:@"my-awesome-db.sql" andStatusBlock:^(BOOL success, NSError *error) {

    // Handle the error to check it has been opened properly
}];

To close it, call -closeLocalDatabaseWithName:andStatusBlock:

Renaming and deleting

To rename and delete your database, we have these two methods:

-renameDatabaseWithName:toName:andStatus:
-deleteDatabaseWithName:andStatus:

Performing queries

Queries are performed with the method -performQuery:withBlock:, which is also block-based.

For example, if you want to look for all the items inside a table (which query is SELECT * FROM tableName), the code would be:

[[AFSQLManager sharedManager]performQuery:@"SELECT * FROM tableName" withBlock:^(NSArray *row, NSError *error, BOOL finished) {

    // Handle each row
}];

The block will be executed on every row, and it will contain an array (row) with each column in that row.

License

AFSQLManager is under MIT license so feel free to use it!

Author

Made by Alvaro Franco. If you have any question, feel free to drop me a line at [email protected]

Latest podspec

{
    "name": "AFSQLManager",
    "version": "1.0.2",
    "summary": "SQL and SQLite manager for iOS.",
    "description": "SQL and SQLite database manage on iOS made easy. Create, open, rename and delete databases with AFSQLManager, a block-driven iOS SQL and SQLite manager class. Perform queries never has been that easy!",
    "homepage": "https://github.com/AlvaroFranco/AFSQLManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Alvaro Franco": "[email protected]"
    },
    "screenshots": "https://raw.github.com/AlvaroFranco/AFSQLManager/master/preview.gif",
    "source": {
        "git": "https://github.com/AlvaroFranco/AFSQLManager.git",
        "tag": "v1.0.2"
    },
    "source_files": [
        "AFSQLManager.h",
        "AFSQLManager.m"
    ],
    "xcconfig": {
        "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libsqlite3"
    },
    "requires_arc": true
}

Pin It on Pinterest

Share This