pinkfoyd Posted January 17, 2006 Share Posted January 17, 2006 (edited) After leave the firebird solution, i search a solution for use mysql here is a listing which work fine : for use it, you need a MYSQL server, admin login & password and a database of course i think the comment are enough so if you have question write it here expandcollapse popup;Test mysql #include <GUIConstants.au3> #include <Constants.au3> ;change here the path to mysql.exe CONST $path_mysql = "D:\Denis\wamp\mysql\bin\" dim $tableau_result $line = "";don't modify this, it's just for variable initialisation ;we create our database request (don't miss the; a the end of each command) $sql = "use pictures;" & @CRLF ;mysql = select the database to use $sql = $sql & "select * from girls;";mysql = request in the base from the girls table ;launch function to create the file _create_mysql_command_file($sql) ; change 'root' by the mysql admin login ; if you have a password, you need to add it with -p parameter, ie : mysql.exe -u YOURLOGIN -p YOURPASSWORD -X < ; $command_sql = $path_mysql & "mysql.exe -u root -X < " & $path_mysql & "sql_command.txt" ; create the mysql process $command = Run(@ComSpec & " /c " & $command_sql, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD); execute the mysql process While 1; get the result returned by mysql.exe command $string_result = $line $line = StdoutRead($command) If @error = -1 Then ExitLoop ;MsgBox(0, "STDOUT read:", $line); display the entire returned result (if you want debug) Wend $tableau_result = _clean_mysql_return($string_result); clean and organize the result for $boucle = 1 to $tableau_result[0];display the result of therequest $reponse = $tableau_result[$boucle]; each result in in the MsgBox(262144,'MySQL Result','Value : ' & @lf & $reponse) Next ;***************************************************** FUNCTION DECLARATION *********************************************************** func _clean_mysql_return($string_result) ; we will clean the XML format result $string_result = StringReplace($string_result,"<row>","") ; delete all <row> $string_result = StringReplace($string_result,"</row>","") ; delete all </row> $string_result = StringReplace($string_result,"<field name=",""); delete all <field name=> $string_result = StringReplace($string_result,"</field>",""); delete all </field> $string_result = StringReplace($string_result,"</resultset>",""); delete all </resultset> $string_result = StringReplace($string_result,">"," = ") ; change all > in = $string_search = chr(34) & "id" & chr(34); = "id" $position_caracter_id = StringInStr($string_result,$string_search); search the position of the first "id" in the string result $string_result = StringRight($string_result,StringLen($string_result) - $position_caracter_id + 1); delete all that is before the first "id"= $string_result = StringStripCR($string_result) ; delete all CR $string_result = StringStripWS($string_result,4) ; delete all useless space $string_result = StringReplace($string_result,chr(34),"") ; delete all " $tableau_result = StringSplit($string_result,@CRLF) $tableau_result[0] = $tableau_result[0]-1 ; delete the last element because is empty return($tableau_result) EndFunc func _create_mysql_command_file($string) $file = FileOpen($path_mysql & "sql_command.txt", 2);2 = Write mode (erase previous contents) FileWrite($file,$string); we write the command in the file FileClose($file) EndFunctest_sql.au3 Edited January 17, 2006 by pinkfoyd Link to comment Share on other sites More sharing options...
pinkfoyd Posted January 18, 2006 Author Share Posted January 18, 2006 (edited) no one interested or not function ?PS : i have changed the function, so now it's more easy to execute mysql request PS2 : oups, i never see this topic before http://www.autoitscript.com/forum/index.ph...ic=17099&st=405 Edited January 18, 2006 by pinkfoyd Link to comment Share on other sites More sharing options...
CelsoSC Posted March 8, 2006 Share Posted March 8, 2006 After leave the firebird solution, i search a solution for use mysqlI'm looking for a solution for use with firebird/interbase enignes... Do you have any suggestion?Thx in advance. Link to comment Share on other sites More sharing options...
cdkid Posted March 8, 2006 Share Posted March 8, 2006 (edited) I've got a library of MySQL funcs already (in my signature) So i wouldn't call this "The one/only.." ~cdkid Edited March 8, 2006 by cdkid AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide! Link to comment Share on other sites More sharing options...
randallc Posted March 9, 2006 Share Posted March 9, 2006 Hi, I had been looking at using a command line for MySQL as @cdkid's obj commands do not seem to accet concatenation of commands. I think , using yours, I could create a concatenated command using my SQLiteEXE functions (see in signature), with "$i_Execute=0", so the commands are created, not executed in SQLite; then used in your function. I may need to post an update.. Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now