Jump to content

MySQL


Patrix
 Share

Recommended Posts

Introduction

MySQL Module binds a third-party mysql library, which provides Squirrel functions to access data from MySQL databases. More information about MySQL database you will find on the internet.

SQL language tutorial: https://www.w3schools.com/sql/
Used SDK: https://downloads.mysql.com/archives/c-c/

Project links:
- Repository
- Download
- Documentation

Usage example

local conn = null

addEventHandler("onInit", function()
{
        conn = mysql_connect("localhost", "root", "", "db_test")

        if (!conn)
                throw "Cannot connect with server database!"

        local result = mysql_query(conn, "SELECT * FROM mdb_users")

        if (!result)
                throw mysql_error(conn) + "\ncode: " + mysql_errno(conn)

        print("Query done " + mysql_num_fields(result))
        local row_assoc = mysql_fetch_assoc(result)

        if (row_assoc)
                print(row_assoc["username"] + " " + row_assoc["email"])
 
        mysql_free_result(result)
})

 

  • Like 2
Link to comment
Share on other sites

  • 2 weeks later...

I'm happy to announce that i've finished working on MySQL module C API update! https://gitlab.com/GothicMultiplayerTeam/modules/mysql/-/releases/0.5

 

Feel free to use the new module that is using 8.0+ API, instead of old 6.1.11 version that was slowly losing support. Also, this module uses experimental setup (native builds instead of cross compiled ones), in time every module maintained by me will be updated to work on the same principle. Propably in near future you can also expect some async calls binds (work for new release) 😉

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...