2

I have 3 textfield in my application which are the following:

  • e-mail
  • username
  • password

I want to enter this data into the MySQL database using Xcode swift

5
  • which data base is are you used SQLite or CoreData Commented May 4, 2016 at 10:53
  • oh ok ok , canyou show your URL and params once Commented May 4, 2016 at 11:01
  • Do you want to connect MySQL server with swift code? Commented May 4, 2016 at 11:05
  • no i want to insert textfield data into mysql localhost server Commented May 4, 2016 at 11:25
  • @teko i have answered if you find it useful don't forget to upvote and acccept Commented May 4, 2016 at 12:18

1 Answer 1

2

Do you want to connect MySql Server externally or your local my SQL database

Here is the way using this library https://github.com/novi/mysql-swift

How to make connection

 let options = Options(host: "db.example.tokyo"...)
    let pool = ConnectionPool(options: options)

    let conn = try pool.getConnection() 
    conn.query("SELECT 1 + 2;")
    conn.release() 

How to get data from database

 let rows: [User] = try pool.execute { conn in
        // The connection is held in this block
        try conn.query("SELECT * FROM users;") // And also it returns result to outside execute block
    }

For more refer the library documentation here

Documentation

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.