Jump to content
ProgAndy

MySQL UDFs (without ODBC)

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

Share this post


Link to post
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ë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
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

Share this post


Link to post
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)

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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ë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

I got it...

$query = "INSERT INTO DECO (Host_Name,Host_UUID,Serial_Number,Location,Mac_Address,Last_User_Name,Last_User_Date_and_Time,Deco_Week,Operating_System,Agent_Execution) VALUES ('Machine 1','hostuuid1','','','','','','','','')"

Share this post


Link to post
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

Share this post


Link to post
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ë 맧ëñ§ë øƒ !ïƒë.

Share this post


Link to post
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.

Share this post


Link to post
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()?

Share this post


Link to post
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

Share this post


Link to post
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

  • Similar Content

    • By RAMzor
      Hello all!
      I got the Acroname Programmable USB Hub based on BrainStem platform. I will use it to manage ports and read current.
      They have development kit (BRAINSTEM DEVELOPMENT KIT) with examples for any languages like C#, C++, LabVIEW and python but no AutoIt.
      The kit include BrainStem2.dll (x32 and x64), BrainStem2_LabVIEW.dll, BrainStem2CLI.dll and many examples.
      Anyone used this dll and implemented it in AutoIt?
      Please share some example for Device Discovering, User LED Flashing or power enable/disable on port to start play with this HUB
      BrainStem Reference 
       
      BrainStem2 lib+example.7z USB HUB User Manual s79-usbhub-3p_v1.10_0.pdf
    • By matwachich
      Hi guys!
      A pretty simple UDF to convert HTML to PDF using wkHTMLtoPDF.
      It uses the C API of the tool (DLL), so no external process, no ActiveX or COM sh*t.
      See the example, and the documentation of wkHTMLtoPDF.
      Cheers
      https://github.com/matwachich/wkhtmltopdf-au3
    • By Skysnake
      This is relevant
      From here https://stackoverflow.com/questions/3454315/is-it-possible-to-pin-a-dll-in-memory-to-prevent-unloading
      I use several UDFs on the Forum to do various things.  Those UDFs work very well.
      Effectively the UDFs are DLL wrappers, that make it possible to access DLL functions easily without the long hard slog of DLLCall() every time.
      However, I have now run into the issue that multiple UDF DLLCalls are slow. Not mind numbingly slow, but slow enough to become noticeable with a large of repeated function calls.
      So I was wondering, is it possible to "load a DLL into memory" and leave it there for the duration of my script's lifetime, avoid repeated DLL on-disk reads with a persistent in memory DLL?
      From Microsoft
      https://docs.microsoft.com/en-us/windows/desktop/dlls/about-dynamic-link-libraries
      Looks like what I want to do is: load-time dynamic linking,
      So next question, (a) how do I do this with AutoIt (b) How would this impact on standard AutoIt type DLL calls?
       
      The point is speed.  Is there a different approach?
      Or am I barking up the wrong tree?
      Skysnake
    • By bladem2003
      Hello,
      i need help to translate the c code to autoit .
      I don't understand the callback function.
       
      #include <windows.h> #include <stdio.h> // native IR Data by PAnsiChar typedef void CALLBACK CallBackPAnsiChar(char*, char*, char*, char*); typedef int (__stdcall *impInitPAnsiChar)(CallBackPAnsiChar); CALLBACK MyCallBackPAnsiChar(char* Protocol, char* Address, char* Command, char* Flags) { printf("\nIR Data received: Protocol: %s, Address: 0x%s, Command: 0x%s, Flags: 0x%s", Protocol, Address, Command, Flags); fflush(stdout); } int main(int argc, char **argv) { impInitPAnsiChar InitPAnsiChar = NULL; // Load DLL file HINSTANCE hinstLib = LoadLibrary(TEXT("USB_IR_Remote_Receiver.dll")); if (hinstLib == NULL) { printf("\nERROR: unable to load DLL\n"); return 1; } // Get function pointer InitPAnsiChar InitPAnsiChar = (impInitPAnsiChar)GetProcAddress(hinstLib, "InitPAnsiChar"); if (InitPAnsiChar == NULL) { printf("\nERROR: unable to find DLL function\n"); FreeLibrary(hinstLib); return 1; } if (InitPAnsiChar(*MyCallBackPAnsiChar)) { printf("\nInit DLL with InitPAnsiChar successfull"); } else { // Unload DLL file FreeLibrary(hinstLib); return 0; } while(1) { } //return 0; }  
    • By Stacker
      Hi all,
      i want to start a new application that capture a screen or image from webcam an read all barcode inside the picture.
      I have test this code https://www.autoitscript.com/forum/topic/27925-webcam-example/
      Works fine for my webcam.
      Now i need to read all barcodes (code 128 code39, no 2d) inside the picture. I have found this https://www.codeproject.com/Articles/42852/Reading-Barcodes-from-an-Image-III
      It's possible to make a dll from VB source i linked  with this  parameters :  filename, Array of barcode founded, error code and launch from Autoit with function ?
      Anyone can help me to make dll and autoit function, i don't know VB.
      Thanks
×
×
  • Create New...