[CLASS] MySQLAPI - MySQL wrapper

Post your working scripts, libraries and tools
bobycom
Posts: 8
Joined: 26 Feb 2015, 07:13

Re: [CLASS] MySQLAPI - MySQL wrapper

19 Aug 2015, 08:10

I checked the A_LastError variable and it contains the value of 127, which means that it can not find the address of a function exported by another DLL. I then opened the Conector C 6.1 with Dependency Walker and found out that there are 3 missing functions inside my KERNEL32.DLL (InitializeConditionVariable, SleepConditionVariableCS and WakeConditionVariable). Then I saw in MSDN that the minimum supported client of those functions is Windows Vista.

If you think that this error code is unambiguous, please add a specific error message according to it.


P.S.
When the libmysql.dll file is missing, the error code is 126. I wasn't able to find a full list of the error codes of the LoadLibrary function.


Edit
I have manually edited the 2 dll's (6.0 and 6.1) in a text editor and deleted a few symbols. When I open the test script the LoadLibrary function returns error code 193. The error code is the same if I try to use the 64-bit version of the DLL or an empty .txt file renamed as .dll.

I hope that this is helpful :)
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

20 Aug 2015, 02:46

Hello bobycom,

thanks for your breakdown. What do you think about this change (replacement for the __New method:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Would you test it, please?
bobycom
Posts: 8
Joined: 26 Feb 2015, 07:13

Re: [CLASS] MySQLAPI - MySQL wrapper

20 Aug 2015, 03:15

I like your code :)

Test results on a Windows XP 32-bit machine:
  • When DLL is missing:
    "Could not find D:\Tests\libmysql.dll!"

  • When Using the 32-bit version of Connector C 6.1:
    "Could not load D:\Tests\libmysql.dll!
    Error code: 127
    The specified procedure could not be found."

  • When using a corrupted or a 64-bit DLL:
    "Could not load D:\Tests\libmysql.dll!
    Error code: 193
    %1 is not a valid Win32 application."

P.S.
I noticed a missing letter in the first message box of the function ("You muSt not instantiate instances of MySQLDB!").
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

20 Aug 2015, 04:02

Thanks again. I've updated the source and the OP.
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Re: [CLASS] MySQLAPI - MySQL wrapper

15 Jan 2016, 19:08

Hello,

Have you an example to retrieve multiple data from MySQL and show data in msgbox.

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus



This returns only Result_ID_Row and no Result_Name_Row !

Thank you for your help :)
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

16 Jan 2016, 04:41

Both ID and Name are belonging to one row. So this might work:

Code: [Select all] [Download] GeSHi © Codebox Plus

SQL := "SELECT ID, NAME FROM list"
If (DB.Query(SQL) = MySQL_SUCCESS)
{
Result := DB.Store_Result()
Result_Row := DB.Fetch_Row(Result)
Result_Id := StrGet(NumGet(Result_Row + 0, 0, "UPtr"), "UTF-8")
Result_Name := StrGet(NumGet(Result_Row + 0, A_PtrSize, "UPtr"), "UTF-8")
DB.Free_Result(Result)
}
MsgBox, 0, , %Result_ID% @ %Result_Name%
Return
*untested*

But I'd suggest to use the additional wrapper functions GetNextRow() or GetResult():

Code: [Select all] [Download] GeSHi © Codebox Plus

SQL := "SELECT ID, NAME FROM list"
If (DB.Query(SQL) = MySQL_SUCCESS)
{
Result := DB.Store_Result()
Result_Row := DB.GetNextRow(Result)
Result_Id := Result_Row[1]
Result_Name := Result_Row[2]
DB.Free_Result(Result)
}
MsgBox, 0, , %Result_ID% @ %Result_Name%
Return
*also untested*
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Re: [CLASS] MySQLAPI - MySQL wrapper

16 Jan 2016, 09:44

Thank you just me this work :)

Spoiler
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Re: [CLASS] MySQLAPI - MySQL wrapper

17 Jan 2016, 19:44

Hi,

how to retrieve the total number (49) and show msgbox with 49 in 0.0002 ?

In phpmyadmin :

Showing rows 0 - 0 (49 total, Query took 0.0002 sec)
SELECT * FROM `mix` WHERE `MIX_OP` = 162

Thank you for your help.
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

18 Jan 2016, 03:06

Code: [Select all] [Download] GeSHi © Codebox Plus

   ; ===================================================================================================================
; Returns the number of rows in a result set.
; Parameters: MYSQL_RES - Pointer to a MYSQL_RES structure.
; Return values: An unsigned 64-bit integer representing the number of rows in a result set.
; ===================================================================================================================
Num_Rows(MYSQL_RES) {
Return DllCall("libmysql.dll\mysql_num_rows", "Ptr", MYSQL_RES, "UInt64")
}
?
Marvin1023
Posts: 45
Joined: 10 Nov 2015, 12:49

Re: [CLASS] MySQLAPI - MySQL wrapper

19 Jan 2016, 08:20

Yes sorry :/
Asus Maximus VIII Extrême - DDR4 16Go - Intel Core i7 - GTX 1080
hot hot 85
Posts: 14
Joined: 27 Dec 2015, 19:34
Facebook: dario maldonado

Re: [CLASS] MySQLAPI - MySQL wrapper

13 Feb 2016, 23:59

Hi all ,is my first time ,I try to use the library ,but appear the next error

---------------------------
MySQL Error!
---------------------------
Connection failed!

2003 - Can't connect to MySQL server on 'lenovo-PC' (10061)
---------------------------
Aceptar
---------------------------

I modify the next info
; Settings
; ======================================================================================================================
UserID := "lenovo" ; User name - must have privileges to create databases
UserPW := "DARIO" ; User''s password
Server := "lenovo-PC" ; Server''s host name or IP address

Database := "Test" ; Name of the database to work with
DropDatabase := False ; DROP DATABASE
DropTable := False ; DROP TABLE Address


I have the libmysql.dll from MySQL Connector C 6.1


The error (2003) Can't connect to MySQL server on 'server' (10061) indicates that the network connection has been refused. You should check that there is a MySQL server running, that it has network connections enabled, and that the network port you specified is the one configured on the server.

Any ideas?
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

14 Feb 2016, 03:14

Did you try to use the IP address?
hot hot 85
Posts: 14
Joined: 27 Dec 2015, 19:34
Facebook: dario maldonado

Re: [CLASS] MySQLAPI - MySQL wrapper

14 Feb 2016, 11:43

just me wrote:Did you try to use the IP address?



I think I resolve the problem.Now I have this error

---------------------------
MySQL Error!
---------------------------
Connection failed!

1130 - Host 'fe80::6dae:72e2:f9ce:ca05%10' is not allowed to connect to this MySQL server
---------------------------
Aceptar
---------------------------
If I use IP Address

show the next error

---------------------------
MySQL Error!
---------------------------
Connection failed!

1130 - Host '192.168.2.5' is not allowed to connect to this MySQL server
---------------------------
Aceptar
---------------------------

Any Ideas?
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

14 Feb 2016, 12:02

No. I suppose that 192.168.2.5 is the client PC's IP address, is it?
hot hot 85
Posts: 14
Joined: 27 Dec 2015, 19:34
Facebook: dario maldonado

Re: [CLASS] MySQLAPI - MySQL wrapper

14 Feb 2016, 12:13

just me wrote:No. I suppose that 192.168.2.5 is the client PC's IP address, is it?



Thanks Just me I Log in I use

mysql> CREATE USER 'dario'@'192.168.2.5' IDENTIFIED BY 'dario';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'dario'@'192.168.2.5'
-> WITH GRANT OPTION;

Now to learn how to use
:)


if I try to use the button add show this error

---------------------------
MySQL Error!
---------------------------
1146: Table 'test.address' doesn't exist

any ideas?
geminbot

Re: [CLASS] MySQLAPI - MySQL wrapper

16 Feb 2016, 15:49

Hi Just Me - Just wanted to thank you for an awesome upgrade to panofish's incredible mysql api wrapper.
It bailed me out of a tight spot.
One thing that gave me trouble was actually using the data after I queried it.
(Ignorance on my part - obviously)
But I wrote a demo AHK script that uses your wrapper.
It's not much but it may help others traveling a similar path to mine.
To use it a single table database is needed.
There should be some data in the table too.
(I did not include a CREATE TABLE sql in this demo.)
I hope this will be helpful -- Thanks again !

Code below:

Code: [Select all] [Expand] [Download] (Untitled.ahk)GeSHi © Codebox Plus

just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

17 Feb 2016, 03:22

Thanks, I added a link in the OP.
hot hot 85
Posts: 14
Joined: 27 Dec 2015, 19:34
Facebook: dario maldonado

Re: [CLASS] MySQLAPI - MySQL wrapper

17 Feb 2016, 21:37

Hi in the code above you are referring to #include mysql2.ahk , where is this file?
just me
Posts: 5460
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: [CLASS] MySQLAPI - MySQL wrapper

18 Feb 2016, 03:11

I guess it's geminbot's private version of Class_MySQLAPI.ahk.
geminbot

Re: [CLASS] MySQLAPI - MySQL wrapper

21 Feb 2016, 20:33

Yes, I aliased the class and called it mysql2.ahk instead of Class_MySQLAPI.ahk.
Sorry about that. I should have changed that back when I sanitized my demo.

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 19 guests