Alek Posted September 29, 2007 Posted September 29, 2007 (edited) im trying make the UDF's using .bat files and mysql.exethis is what i got so far but it dosent work properly.lets say i try to querry a whole table, and it returns only some of the data in the table, anyone know why not??SELECT * FROM accountit works great if i try to query for a specific ting, likeSELECT name FROM account WHERE id=1expandcollapse popup$Host = "localhost" $User = "root" $Pass = "root" $port = "3306" $DB = "my_db" $Test = _MySQL_Query("SELECT * FROM table") if Not @error then for $x = 1 to $Test[0] if $Test[$x] <> "" Then MsgBox(0,"",$Test[$x]) Next Else MsgBox(0,"",$Test) EndIf Func _MySQL_Query($Query) ;im going to set @scriptDir to @tempdir or some other dir later,this is just for testing FileDelete(@ScriptDir & "\temp.bat") FileDelete(@ScriptDir & "\temp.sql") FileWrite(@ScriptDir & "\temp.sql",$Query) FileWrite(@ScriptDir & "\Temp.bat","MYSQL -h "& $Host &" --user="& $User &" --password="& $Pass &" --port="& $port &" "& $DB &" < temp.sql") $MySQL = Run(@ScriptDir & "\Temp.bat", @ScriptDir, @SW_HIDE,6) $line = StdoutRead($MySQL) $line = StdoutRead($MySQL) While 1 $line = StdoutRead($MySQL) If @error Then ExitLoop $Line = StringSplit($line,@CRLF) Return $line Wend While 1 $line = StderrRead($MySQL) If @error Then ExitLoop SetError(1) Return "Error:" & $line Wend EndFuncmysql.exe, place it in the same path as the script Edited September 29, 2007 by Alek [font="Impact"]Never fear, I is here.[/font]
Danny35d Posted September 29, 2007 Posted September 29, 2007 May be these links will help you:MySQL UDFAutoIT MySQL and PHP AutoIt Scripts:NetPrinter - Network Printer UtilityRobocopyGUI - GUI interface for M$ robocopy command line
Alek Posted September 29, 2007 Author Posted September 29, 2007 May be these links will help you:MySQL UDFAutoIT MySQL and PHPi have look at both.the one using ODBC 3.51 is slow and you need to install ODBC 3.51 to use the application that i makethe one using php i couldent get to work properlythats why im gonna try an make some udfs using .bat, it should be faster then odbc, atleast i hope it is, and easyer to use then the php functions. [font="Impact"]Never fear, I is here.[/font]
tAKTelapis Posted September 30, 2007 Posted September 30, 2007 First of all, You have this line twice: $line = StdoutRead($MySQL) And secondly, it returns all 3 columns of data when i execute your script. Afraid i cannot replicate your problem. How many rows of data should it return from your table?
Alek Posted September 30, 2007 Author Posted September 30, 2007 First of all, You have this line twice: $line = StdoutRead($MySQL)And secondly, it returns all 3 columns of data when i execute your script.Afraid i cannot replicate your problem.How many rows of data should it return from your table?i have $line = StdoutRead($MySQL) twice because atleast on my computer the two first StdoutRead returns usless dataand i have around 50ish rows of data [font="Impact"]Never fear, I is here.[/font]
SiteMaze Posted February 20, 2008 Posted February 20, 2008 Great method, but is there another way of exporting the SQL query output to a CSV file? stdoutread is not very reliable to read 1000s of lines of data. Another option is the tee mysql method but it saves the headers and tails too. I was hoping for a cleaner way in mysql commandline to export the query to a csv. Arsenal Football Fan Club in Singapore
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