AFSQLManager

适用于iOS的SQL和SQLite管理器。(SQL and SQLite manager for iOS)

Github星跟踪图

AFSQLManager

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 alvarofrancoayala@gmail.com

主要指标

概览
名称与所有者AlvaroFranco/AFSQLManager
主编程语言Objective-C
编程语言Objective-C (语言数: 2)
平台iOS
许可证MIT License
所有者活动
创建于2014-04-17 17:35:01
推送于2017-04-17 09:37:45
最后一次提交2014-07-07 00:36:02
发布数3
最新版本名称v1.0.2 (发布于 )
第一版名称v1.0 (发布于 )
用户参与
星数179
关注者数8
派生数21
提交数25
已启用问题?
问题数4
打开的问题数3
拉请求数2
打开的拉请求数1
关闭的拉请求数1
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?