Code Monkey home page Code Monkey logo

sqliteclasses's Introduction

sqliteClasses

Build Status CocoaPods Version Swift4 compatible Platform Carthage compatible Join the chat at https://gitter.im/osoftz_iOS/sqliteClasses

A type-safe, Swift-language layer over SQLite3.

sqliteClasses provides compile-time confidence in SQL statement syntax and intent.

Features

  • A pure-Swift interface
  • A type-safe, optional-aware SQL expression builder
  • A flexible, chainable, lazy-executing query layer
  • Automatically-typed data access
  • A lightweight, uncomplicated query and parameter binding interface
  • Developer-friendly error handling and debugging
  • Full-text search support
  • Well-documented
  • Extensively tested
  • SQLCipher support via CocoaPods
  • Active support at StackOverflow, and Gitter Chat Room (experimental)

Usage

/* *********************Creating and Assigning DB************************* */
         createDB(DBName: "First_DB"){
            data, error in
            if data == nil && error == nil{
                print("Table not created")
            }
            else if data == nil{
                print(error!)
            }
            else{
                self.data_base = data!
                print("Database created")
            }
        }
        /* *********************Creating and Assigning DB************************* */
        
        
        /* *********************Creating and print Table************************* */
        let columnNames = ["ID","Name","Age","Mobile","Mail"]
        let dataType = [0,2,2,2,2]
        let unique = [false,false,false,true,true]
        let primay = [true,false,false,false,false]

        let aa = createTable(tableName: "SecondTable", DB: self.data_base, columnNames: columnNames, dataType: dataType, isUnique: unique, isPrimary: primay)
        if (aa.0) {
            print("table created")
        }
        else{
            print("Error while creating table\(aa.1!)")
        }


        let columnNames1 = ["Name","Age","Mobile","Mail"]
        let dataType1 = [2,2,2,2]

        let values = ["Siva","28","96684579","[email protected]"]

        let bb = insertInTable(tableName: "SecondTable", DB: self.data_base, columnNames: columnNames1, dataType: dataType1, values: values)

        if(bb.0){
            let ID = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 0, column: "ID")
            let Name = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Name")
            let Age = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Age")
            let Mobile = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Mobile")
            let Email =  selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Mail")
            if Name.1 == nil{
                print("ID \(ID.0!)\nNames array \(Name.0!)\nAge \(Age.0!)\nMobile \(Mobile.0!)\nEmail \(Email.0!)")
            }
        }
        else{
            print("Error while inserting \(bb.1!)")
        }
        /* *********************Creating and print Table************************* */

        /* *********************Upadte and print Table************************* */
        let cc = updateTable(DB: self.data_base, tableName: "SecondTable", where_columName: "ID", where_value: "2", where_dataType: 0, columName: "Name", value: "Sureshkumar", dataType: 2)

        if(cc.0){
            let ID = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 0, column: "ID")
            let Name = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Name")
            let Age = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Age")
            let Mobile = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Mobile")
            let Email =  selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Mail")
            if Name.1 == nil{
                print("ID \(ID.0!)\nNames array \(Name.0!)\nAge \(Age.0!)\nMobile \(Mobile.0!)\nEmail \(Email.0!)")
            }
        }
        else{
            print("Error while update \(cc.1!)")
        }
        /* *********************Creating and print Table************************* */
        
         let dd :(Bool?, Error?) = deleteRow(DB: self.data_base, tableName: "SecondTable", dataType: 0, column: "ID", value: "1")
        if (dd.0!){
            let ID = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 0, column: "ID")
            let Name = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Name")
            let Age = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Age")
            let Mobile = selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Mobile")
            let Email =  selectTable(DB: self.data_base, tableName: "SecondTable", dataType: 2, column: "Mail")
            if Name.1 == nil{
                print("ID \(ID.0!)\nNames array \(Name.0!)\nAge \(Age.0!)\nMobile \(Mobile.0!)\nEmail \(Email.0!)")
            }
        }
        else{
            print("Error while Delete \(dd.1!)")
        }

Read the documentation or explore more, interactively, from the Xcode project’s playground.

SQLite.playground Screen Shot

For a more comprehensive example, see this article and the companion repository.

Installation

Note: sqliteClasses requires Swift 4.1 (and Xcode 9.3).

Carthage

Carthage is a simple, decentralized dependency manager for Cocoa. To install sqliteClasses with Carthage:

  1. Make sure Carthage is installed.

  2. Update your Cartfile to include the following:

    github "osoftz/sqliteClasses"
  3. Run carthage update and add the appropriate framework.

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. To install sqliteClasses with CocoaPods:

  1. Make sure CocoaPods is installed. (sqliteClasses requires version 1.0.0 or greater.)

    # Using the default Ruby install will require you to use sudo when
    # installing and updating gems.
    [sudo] gem install cocoapods
  2. Update your Podfile to include the following:

    use_frameworks!
    
    target 'YourAppTargetName' do
        pod 'sqliteClasses'
    end
  3. Run pod install --repo-update.

Swift Package Manager

The Swift Package Manager is a tool for managing the distribution of Swift code.

  1. Add the following to your Package.swift file:
dependencies: [
    .package(url: "https://github.com/osoftz/sqliteClasses.git", from: "0.11.5")
]
  1. Build your project:
$ swift build

Manual

To install sqliteClasses as an Xcode sub-project:

  1. Drag the SQLite.xcodeproj file into your own project. (Submodule, clone, or download the project first.)

    Installation Screen Shot

  2. In your target’s General tab, click the + button under Linked Frameworks and Libraries.

  3. Select the appropriate SQLite.framework for your platform.

  4. Add.

Some additional steps are required to install the application on an actual device:

  1. In the General tab, click the + button under Embedded Binaries.

  2. Select the appropriate SQLite.framework for your platform.

  3. Add.

Communication

See the planning document for a roadmap and existing feature requests.

Read the contributing guidelines. The TL;DR (but please; R):

Author

License

sqliteClasses is available under the MIT license. See the LICENSE file for more information.

Related

These projects enhance or use sqliteClasses:

Alternatives

Looking for something else? Try another Swift wrapper (or FMDB):

sqliteclasses's People

Contributors

osoftz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.