Skip to content

parthsaxena/SwiftSQL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

SwiftSQL

A framework to facilitate SQL connections in Swift using a host server to route requests.

Installation

Transfer ConnectionManager.swift in the Swift folder to your Xcode project. Change the QUERY_URL, SIMPLE_QUERY_URL, AUTH_URL, and TEST_URL variables according to your server configuration.

Similarly, change the values of host, user, password, and database in index.js in the Server folder.

Make sure Node.js is installed on your server. Run npm install to install dependencies and node index.js to start the server.

Usage

There are some built-in template functions in the framework, but the process of implementing your own methods is straightforward. These template functions include a standard authenticateUser function, testConnection function, complexQuery function, executeQuery function, and a retrievePosts function to retrieve data of some sort.

To run any of these functions:

ConnectionManager.sharedInstance.function() {
  (result: AnyObject) in
    // code
}

Example

ConnectionManager.sharedInstance.complexQuery("SELECT * FROM posts WHERE posted_by='parthsaxena'") {
    (result: AnyObject) in
    if let posts = result as? [[String: AnyObject]] {
      print("Retrieved (\(posts.count)) posts.")
      for post in posts {
        self.posts.append(post)
      }
      self.tableView.reloadData()
    }
}

Credits

Parth Saxena

About

A scalable framework to make SQL queries in Swift.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published