SQLite Poor content

Source: Internet
Author: User
Tags sqlite

SQLite's official website

http://addons.mozillan.org/firefox/addon/sqlite-manager/

http://www.sqlite.org

Sqlite3 *sqlite = nil;

NSString *filepath = [Nshomedirectory () stringbyappendingpathcomponent:@ "Documents/data.file"];

Open Database

int result = Sqlite3_open ([FilePath utf8string], &sqlite);

if (Result!=sqlite_ok) {

NSLog (@ "Create failed!!! ");

return;

}

To create a table's SQL statement

NSString *sql = @ "CREATE TABLE IF not EXISTS usertable (userName text PRIMARY KEY, password text,email text)";

Execute SQL statement

Char *error;

result = Sqlite3_exec (SQLite, [SQL Utf8string], NULL, NULL, &ERROR);

if (Result! = SQLITE_OK) {

NSLog (@ "Failed to create database:%s", error);

return;

}

Plug in a piece of data

INSERT OR REPLACE into usertable (username,password,email) VALUES (?,?,?);

Update One piece of data

UPDATE usertable Set password = ' where userName = ';

Querying data

SELECT UserName, password,eamil from usertable where userName = ';

Delete data

DELETE from usertable WHERE username = ';

Close the database

Sqlite3_close (SQLite);

SQLite Poor content

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.