Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yashthaker7/tydb
Simplest SQLite manager for iOS.
https://github.com/yashthaker7/tydb
ios objective-c sqlite sqlite-database sqlite3 sqlitemanger swift swift4 tydb xcode
Last synced: 3 months ago
JSON representation
Simplest SQLite manager for iOS.
- Host: GitHub
- URL: https://github.com/yashthaker7/tydb
- Owner: yashthaker7
- Created: 2017-10-14T07:18:45.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-27T12:40:54.000Z (over 6 years ago)
- Last Synced: 2024-10-13T02:21:20.918Z (3 months ago)
- Topics: ios, objective-c, sqlite, sqlite-database, sqlite3, sqlitemanger, swift, swift4, tydb, xcode
- Language: Objective-C
- Homepage:
- Size: 42 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Simplest SQLite manager for iOS.
Setup Instructions
---------
Manually:
1. Add `Database` folder to your project.
2. Add `libsqlite3.tbd` or `libsqlite3.0.tbd` to Project -> General -> Linked Frameworks and Libraries.
3. Import `DBManager.h` to AppDelegate and call below method in didFinishLaunchingWithOptions.
```objc
[DBManager copyDatabaseIfNeeded];
```
How to use
---------Create table
---------
```objc
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
[data setObject:@"Yash" forKey:@"Name"];
[data setObject:@"[email protected]" forKey:@"Email"];[DBManager createTable:@"Users" withDictionary:data]; // pass dictionary and table name.
```
Insert data
---------
```objc
NSMutableDictionary *data = [[NSMutableDictionary alloc] init];
[data setObject:@"Yash" forKey:@"Name"];
[data setObject:@"[email protected]" forKey:@"Email"];[DBManager insertData:data tableName:@"Users"]; // pass dictionary and table name.
```
Get single data or find single data with ID
---------
```objc
NSArray *user = [[NSArray alloc] initWithArray:[DBManager findDataWithId:2 tableName:@"Users"]]; // pass id and table name.
```
Get or find data with query
---------
```objc
NSString *query = [NSString stringWithFormat:@"select * from Users"];
NSArray *user = [[NSArray alloc] initWithArray:[DBManager findDataWithQuery:query]]; // pass query.
```
Get all data
---------
```objc
NSArray *users = [[NSArray alloc] initWithArray:[DBManager getAllData:@"Users"]]; // pass table name.
```
Delete data with ID
---------
```objc
BOOL delete = [DBManager deleteDataWithId:1 tableName:@"Users"]; // pass id and table name.
```
Update data with ID
---------
```objc
NSMutableDictionary *updateData = [[NSMutableDictionary alloc] init];
[updateData setObject:@"update" forKey:@"Name"];
[updateData setObject:@"[email protected]" forKey:@"Email"];[DBManager updateData:updateData id:1 tableName:@"Users"]; // pass dictionary, id and table name.
```
Get database path
---------
```objc
NSString *getPath = [DBManager getDBPath];
```