Some usages in Sqlite.swift

Source: Internet
Author: User

Sqlite.swift:https://github.com/stephencelis/sqlite.swift

        Let filemgr = Nsfilemanager.defaultmanager () Let dirpaths = Nssearchpathfordirectoriesindomains (. Documentdirectory,. Userdomainmask, true) let Docsdir = Dirpaths[0] as String var databasepath = Docsdir.stringbyappendingpathco Mponent ("dbname.db") Let db = Database (databasepath) Let mytable = db["tablename"] db.create (table:l OGs, ifnotexists:true) {T in T.column (expression<int64> ("id"), PrimaryKey:. AutoIncrement) T.column (expression<string> ("Column1"), Unique:false) T.column (expression<s Tring> ("Column2")) T.column (expression<string> ("Column3"), Unique:false)}//INSERT, return the inserted rowID if let Insertid = Logs.insert (expression<string> ("Column1") <-"AAAAA",expression<string> ("Col        Umn2 ") <-" bbbbb ", expression<string> (" Column3 ") <-" CCCCC ") {println (" inserted ID: \ (insertid) ") }//query, descending query 5 "cloumn1"The entry with the field "AAAAA" let result = Mytable.filter (expression<string> ("cloumn1") = = "AAAAA"). Order (Expression<int64  > ("id"). desc). Limit (5) for log in result {Pritln (log[expression<string> ("Column2")})}

Some usages in Sqlite.swift

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.