Jump to content

MySQL UDFs (without ODBC)


ProgAndy
 Share

Recommended Posts

Updated for AutoIt v3.3.2.0. Download still in first post ;)

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Just thinking outloud here.

I added the checks, null pointers, invalid syntax checks, etc, but still am, randomly, getting invalid data from the server. I have not isolated where the issue is. Granted, after adding the checks, more than 80% of the occurances have disappeared, so initially that was the solution.

So then, i took your 2nd peice of advice, and added the reconnect command to the connection scheme, so that it would always attempt to reconnect to the mysql server, instead of perhaps passing a command via the dll to a socket that no longer exists. And, that removed a few more % of the failures.

But,the fialures still exist. So, i decided it would be useful, everytime i do my XMPP presence keep alive, that i would include a mysql refresh as well. One that just pulls your current name from the sql server (from a specific database that only contains a fixed amoutn of names, so no excess overhead there). So that the connectio to the server stays active. And, that killed yet another % of the failures.

But still they persist.

I have to wonder if it is the dll itself causing the issue. Ie, calling it too many times. In my case, the base # of calls per minute is anywhere from 3-5. However, during peak load times, and if we have all of our people online in the interface, it could potentially do 30-40x that amount of traffic per minute. Granted, it's very easy for me to parse out that information, but i'm wondering, if we are calling it so often, from the server, ie, using the DLL to pass commands to the server, get the response, etc, and then parse again, are we hiting a collision point?

Would it be easier, or a possible fix to just not use dll call, and instead use the Autoit Plugin code instead for ach of the functions in the dll? I dunno, just thinking outloud here. Right now, i'm coding a REST interface (which i have done), and am now working on a POST browser for autoit, that allows me to pull/set data on the sql server via my website, instead of relying on libmysql.dll. As if the website doesn't process it, i wont get -1 erors, or autoit fail errors, or program errors.

Thoughts?

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

I don't know if the dll is causing the problems. Currentyl I included the one from the PHP 5.3 package, so it should be fine. When you are properly freeing results after uasge i can't see problems so far. Try to create some loggin with _MySQL_Stat or something like that, maybe you can find some repeating patterns.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

_MySQL_Num_Rows($res) - still returns a very large number.. wrong and invalid - and the _MySQL_Num_Fields($res) function is fine.

I dont know if i have downloaded an old version of MySQL.au3 ...

anyways, I changed "unit64" to "unit" in MySQL.au3 on line 1376. Now returns the right number.

From:

Local $rows = DllCall($ghMYSQL_LIBMYSQL, "uint64", "mysql_num_rows", "ptr", $result)

To:

Local $rows = DllCall($ghMYSQL_LIBMYSQL, "uint", "mysql_num_rows", "ptr", $result)

Link to comment
Share on other sites

_MySQL_Num_Rows($res) - still returns a very large number.. wrong and invalid - and the _MySQL_Num_Fields($res) function is fine.

I dont know if i have downloaded an old version of MySQL.au3 ...

anyways, I changed "unit64" to "unit" in MySQL.au3 on line 1376. Now returns the right number.

From:

Local $rows = DllCall($ghMYSQL_LIBMYSQL, "uint64", "mysql_num_rows", "ptr", $result)

To:

Local $rows = DllCall($ghMYSQL_LIBMYSQL, "uint", "mysql_num_rows", "ptr", $result)

I bet you are not using the current AutoIt stable (v3.3.2.0). Previous versions of AutoIt had a bug with uint64 as return-type in DLLCall.

Since this is fixed in AutoIt 3.3.2.0, your report is no bug. Also, uint64 is correct in this call according to the API-documentation, so you must not change the types.

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

I'm trying to use this to Insert, and it keeps error'ing out.. ? Using this to test...

$query = "Insert Into Deco VALUES (machine,23452-sdf23f43-34f34f-34f34f-34f34f,kj2h342,Westbury,3e-3e-32-5t-6h-6e-34,nslijhs\gthompson1,1/15/10-05:05:05,Deco 01/01/10,Windows XP,1/15/10)"
$mysql_bool = _MySQL_Real_Query($MysqlConn, $query)
If $mysql_bool = $MYSQL_SUCCESS Then
    MsgBox(0, '', "Query OK")
Else
    $errno = _MySQL_errno($MysqlConn)
    MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn))
EndIf
Link to comment
Share on other sites

I'm trying to use this to Insert, and it keeps error'ing out.. ? Using this to test...

$query = "Insert Into Deco VALUES (machine,23452-sdf23f43-34f34f-34f34f-34f34f,kj2h342,Westbury,3e-3e-32-5t-6h-6e-34,nslijhs\gthompson1,1/15/10-05:05:05,Deco 01/01/10,Windows XP,1/15/10)"
$mysql_bool = _MySQL_Real_Query($MysqlConn, $query)
If $mysql_bool = $MYSQL_SUCCESS Then
    MsgBox(0, '', "Query OK")
Else
    $errno = _MySQL_errno($MysqlConn)
    MsgBox(0,"Error:",$errno & @LF & _MySQL_error($MysqlConn))
EndIf

IIRC you need to specify column names too on that insert:

$usql = "INSERT INTO `TABLE` ('name', `id`) VALUES ('name', '330')"

works for me :D

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Additionally you must not forget to use quotation-marks for strings :D

..,23452-sdf23f43-34f34f-34f34f-34f34f,...

should be

...,'23452-sdf23f43-34f34f-34f34f-34f34f',...

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Then tell me what error you get. My crystal ball is broken.

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

First off, if I use single quotes, it doesn't work at all.. so when I simplify this to a single item being entered it's a little easier to decipher.

Can you give me the exact break down with how the line SHOULD read?

$query = "INSERT INTO DECO (Host_Name) VALUES (machineabc123)"

1054 Unknown Column 'machineabc123' in 'field list'

If I use single quotes...

$query = "INSERT INTO DECO ('Host_Name') VALUES ('machineabc123')"

1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near "Host_name') VALUES ('machineabc123')' at line 1

So... even that error message shows that it seems to be parsing me line incorrectly with the single and double quotes.

Edited by GregThompson
Link to comment
Share on other sites

Just to explain why it failed:

Table-Names, Database-Names and Field-names have to be without quotes. If you want, you can use backticks ( ` -> `field_name`)

To insert strings, you have to use single-quotes. ( 'this is a string' )

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Just to explain why it failed:

Table-Names, Database-Names and Field-names have to be without quotes. If you want, you can use backticks ( ` -> `field_name`)

To insert strings, you have to use single-quotes. ( 'this is a string' )

Not sure if this is correct with the version of libmysql you are using. In my code, i use quotes around database, table, and field names, to ensure they are proper, and it works without issue. In his case, he wasn't using the full field map for his table, thus it had no idea where to put it :D

-_-------__--_-_-____---_-_--_-__-__-_ ^^€ñ†®øÞÿ ë×阮§ wï†høµ† ƒë@®, wï†høµ† †ïmë, @ñd wï†høµ† @ †ïmïdï†ÿ ƒø® !ïƒë. €×阮 ñø†, bµ† ïñ§†ë@d wï†hïñ, ñ@ÿ, †h®øµghøµ† †hë 맧ëñ§ë øƒ !ïƒë.

Link to comment
Share on other sites

Oh true, sorry for the mistake. I will have to update soon.

I bet you are not using the current AutoIt stable (v3.3.2.0). Previous versions of AutoIt had a bug with uint64 as return-type in DLLCall.

Since this is fixed in AutoIt 3.3.2.0, your report is no bug. Also, uint64 is correct in this call according to the API-documentation, so you must not change the types.

Link to comment
Share on other sites

getting an autoit.exe crash by connecting after connection error trying example test.au3 in mysql-package

but it does not crash if i call _MySQL_Init() before the 2nd connection

do i have to call _MySQL_Close() before that 2nd _MySQL_Init()?

Link to comment
Share on other sites

After using _MySQL_Close, you have to call _MySQLInit again, since _MySQL_Close frees the memory allocated with _MySQL_Init. You hsould also not use _MaySQL_Init again when the memory is not freed, so call _MySQL_Close before.

Btw: when using 2 variables, you can have two open connections, one with each varibale :D

Edited by ProgAndy

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...