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

Updated for AutoIt v3.3.2.0. Download still in first post :evil:

The link is still not working for me. ;)

Edit: Nm, it's just really slow.

Edited by EndFunc

EndFuncAutoIt is the shiznit. I love it.

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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Colduction
      Hi AutoIt Scripters/Programmers. I have a question about MIME Tools for Notepad++:
      I've recently found a UDF about Base64 in forum, but they can't decode\encode correctly some emojis , other UTFs and etc. so i decided to use mimeTools.dll of Notepad++ or main site
      My problem is how to use this dll in AutoIt Language?

      I will be happy with your comments and answers❤ Thanks.
    • By FrancescoDiMuro
      Good morning Forums 
      In these days, I am working on a project that involved me to use some Windows APIs to obtain some information about Terminal Servers.
      I'm doing this using wtsapi32.dll in a VBA Project, but, the lack of knowledge about few things threated in the articles make this quite difficult to
      implement and understand at the same time.
      The most difficult thing I'm facing is "translating" C/C++ functions or struct in VBA when pointers are used, or pointers of pointers, and so on.
      Since VBA seems to not have a pointer type, to make those functions work I need to implement other functions taken from other DLLs, and this confuses me a lot.
      For example, starting from this code, I splitted all the functions and all the definitions to understand why they are there, and why I need to use them.
      At the end, I've found out that the code I was going to implement starting from the functions provided in the Microsoft Docs won't be ever be able to work without some supplementary functions which are not mentioned anywhere.
      So, I was wondering if someone would please point me out to a good and practical exaplanation about pointers (in general) or specifically for VBA, because I need to use them quite often in these days, and I'd like to understand what I am doing.
      Thanks in advance.

      Best Regards and Stay at home 🏡
       
    • By zuladabef
      All my scripts were working fine and now I am getting this error.  How do I resolve it?  Which folder(s) do the DLLs need to be in?
      ! Dll not found or Call Dll error !  
    • By argumentum
      $sQueryUpdateTime = "select intUpdateTime from tblStudies " . $where . " ORDER BY intUpdateTime DESC limit 1"; $rs = mysqli_query($conn, $sQueryUpdateTime); $row = mysqli_fetch_assoc($rs); the above used to take 300+ ms. to query. Then I set it as index and takes 30 ms. Cool.
      $sQuery = "select * from tblStudies " . $where . " ORDER BY StudyDate DESC limit $offset,$rows"; // takes 30 ms. on the indexed int $sQuery = "select * from tblStudies " . $where . " ORDER BY StudyDate DESC , PatientName ASC limit $offset,$rows"; // takes 300 ms. due to "PatientName" been a text field, even as I did index it So my observation is that "PatientName" takes a long time to sort, even tho "$rows = 20". Sorting text in 20 rows should be fast.
      ..tho, I find that any 2nd argument in the ORDER BY is just slow.
      Is there a way to query this in a way to have a faster result back ?
      Thanks
      PS: added ADD INDEX `StudyDate_2` (`StudyDate`, `PatientBirthDate`) USING BTREE;  and searched by those two with not much speed change ( StudyDate and PatientBirthDate are integer ).
    • By argumentum
      I was thinking but I don't have the experience, so you may have the experience.
      I was thinking to chop a DB with 100.000 ( 20 columns ) in 10.000 DB chunks ( 10 DBs ) and query concurrently all of them to speed up a search, then add the results. Is that a sound idea ? Or will I run in trouble down the road. Should a DB better be keep in one piece ?
      The DB is now in MySQL. I wanna do all this chopping and use SQLite. 
      Thanks
      [solved]
×
×
  • Create New...