Autoit - Firebird sql Combo,返回数据为csv而不是XML

时间:2014-02-24 15:08:24

标签: sql xml firebird autoit

我和另一个人在某个项目上走得很远,项目已经结束了。

我们使用autoIT(这是一个基本脚本languange)

模拟游戏机器人机器人

但它也连接到FIREBIRD sql数据库 我不确定SQl是否只能将输出返回到XML而不是.csv

也许有人可以为我解答这个问题

我作为XML返回显示为:(这不是首选,因为我必须进行大量的字符串替换等)

 <results><metadata><fields><name value="NAME" alias="NAME" type="5" size="80"       scale="0" /><name value="SETCODE" alias="SETCODE" type="5" size="8" scale="0" /><name value="NORMALBUY" alias="NORMALBUY" type="7" size="4" scale="3" /><name value="NORMALSELL" alias="NORMALSELL" type="7" size="4" scale="3" /><name value="FOILBUY" alias="FOILBUY" type="7" size="4" scale="3" /><name value="FOILSELL" alias="FOILSELL" type="7" size="4" scale="3" /><name value="RARITY" alias="RARITY" type="5" size="6" scale="0" /><name value="CARDNO" alias="CARDNO" type="5" size="6" scale="0" /><name value="NORMALMAX" alias="NORMALMAX" type="7" size="4" scale="0" /><name value="NMAXSTOCK" alias="NMAXSTOCK" type="7" size="4" scale="0" /><name value="FOILMAX" alias="FOILMAX" type="7" size="4" scale="0" /><name value="FMAXSTOCK" alias="FMAXSTOCK" type="7" size="4" scale="0" /><name value="NWISHPRIO" alias="NWISHPRIO" type="7" size="4" scale="0" /><name value="FWISHPRIO" alias="FWISHPRIO" type="7" size="4" scale="0" /><name value="NCATID" alias="NCATID" type="7" size="4" scale="0" /><name value="FCATID" alias="FCATID" type="7" size="4" scale="0" /><name value="NCHECKSUM" alias="NCHECKSUM" type="5" size="40" scale="0" /><name value="FCHECKSUM" alias="FCHECKSUM" type="5" size="40" scale="0" /><name value="REMARKS" alias="REMARKS" type="5" size="120" scale="0" /></fields></metadata><data><row num="1" ><NAME>Duty-Bound Dead                                                                 </NAME><SETCODE>M13     </SETCODE><NORMALBUY>1.e-003</NORMALBUY><NORMALSELL>4.e-003</NORMALSELL><FOILBUY>3.e-003</FOILBUY><FOILSELL>1.5e-002</FOILSELL><RARITY>C     </RARITY><CARDNO>92    </CARDNO><NORMALMAX>12</NORMALMAX><NMAXSTOCK>12</NMAXSTOCK><FOILMAX>0</FOILMAX><FMAXSTOCK>0</FMAXSTOCK><NWISHPRIO>20</NWISHPRIO><FWISHPRIO>20</FWISHPRIO><NCATID>45504</NCATID><FCATID>45505</FCATID><NCHECKSUM>3063484788-4270110158                   </NCHECKSUM><FCHECKSUM>3063484788-4041915094                   </FCHECKSUM><REMARKS>Perfect                                                                                                                 </REMARKS></row></data></results> 

但我只对我的数据返回感兴趣(最好我可以选择我自己的分隔符;)

Duty-Bound_Dead;M13;0.001;0.004;0.003;0.015;C;922;2;1;0;0;20;20;45504,45505;3063484788-4270110158;3063484788-4041915094;Perfect                                                       

任何人都有这方面的经验吗?

1 个答案:

答案 0 :(得分:0)

我做了一些搜索,完成了一些经验,我得到了一些关于你的问题的信息。

“El Torro”实际上有一个Firebird SQL Lib,这里是引用。 我以前一直在工作,所以我会给你一个在互联网上加上Lib本身的例子!

以下是示例:

#include <FireBird.au3>
Local $wer Global $h_fbDll = DllOpen("C:\bird\bin"& "\fbdll4vb20.dll")
Global $servername="192.168.0.5"
Global $sDBName="C:\Program Files\Firebird\Firebird_1_5\bin\Zimkps.gdb"
Local $sUsername = "sysdba" Local $sPassword = "masterkey"
;_FireBird_Help($h_fbDll)
_FireBird_ConnectDatabase($h_fbDll, $servername, $sDBName, $sUsername, $sPassword)
;_FireBird_About($h_fbDll)
;_FireBird_Help($h_fbDll) 
ConsoleWrite( _FireBird_ExecuteStatement($h_fbDll,"select * from tubaina"))
exit

有自己的本身:

include-once
;#INDEX#====================================================================
; Title .........: _FireBird.au3
; Description ...: FireBird, Interbase dll udf.
; Author ........: Stephen Podhajecki (Eltorro) 
; ============================================================================== 

; #CURRENT# ======================================================================
;_FireBird_Check
;_FireBird_About
;_FireBird_SetDebug
;_FireBird_CreateDatabase
;_FireBird_SetPageBuffers
;_FireBird_ConnectEmbededDatabase
;_FireBird_ConnectDatabase 
;_FireBird_DisConnectDatabase
;_FireBird_ExecuteBatch
;_FireBird_ExecuteSelect 
;_FireBird_ExecuteStatement
;_FireBird_Help
; ================================================================================

; #INTERNAL_USE_ONLY# ============================================================
;__FireBird_GetBstr
; ================================================================================ 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_Check
; Description ...: Test function returns the same value given. 
; Syntax ........: _FireBird_Check($iCheck)
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $iCheck - IN - 
; Return values .: Success - $iCheck 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================
Func _FireBird_Check($h_fbDll,$iCheck)     
    Local $vRet = DllCall($h_fbDll, "int", "Check", "long", $iCheck)     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_Check 

; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_About 
; Description ...: Shows about message 
; Syntax ........: _FireBird_About() 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================
Func _FireBird_About($h_fbDll)     
    Local $vRet = DllCall($h_fbDll, "none", "About")     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_About 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_SetDebug 
; Description ...: Turns debugging on or off 
; Syntax ........: _FireBird_SetDebug($xdebug) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $fDebug - IN True or false 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================
Func _FireBird_SetDebug($h_fbDll,$fDebug)     
    Local $vRet = DllCall($h_fbDll, "int", "SetDebug", "int", $fDebug)    
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_SetDebug 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_CreateDatabase 
; Description ...: Creates a database 
; Syntax ........: _FireBird_CreateDatabase($sServerName, $sDBName, $sUsername, $sPassword, $iWriteMode = 1,$iDialect = 3) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $sServerName - IN - 
;                  $sDBName - IN - 
;                  $sUsername - IN - 
;                  $sPassword - IN - 
;                  $iWriteMode - IN/OPTIONAL - 
;                 $iDialect  - IN/OPTIONAL - 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: Overwrites existing database if it exists unless it is being use
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================
Func _FireBird_CreateDatabase($h_fbDll,$sServerName, $sDBName, $sUsername, $sPassword, $iWriteMode, $iDialect = 3)     
    Local $tagfbCreate = "char[%d];char[%d];char[%d];char[%d]"     
    $tagfbCreate = StringFormat($tagfbCreate, StringLen($sServerName) + 1, StringLen($sDBName) + 1, StringLen($sUsername) + 1, StringLen($sPassword) + 1, $iWriteMode = 1, $iDialect = 3)     
    Local $t_fbCreate = DllStructCreate($tagfbCreate)     
    DllStructSetData($t_fbCreate, 1, $sServerName)     
    DllStructSetData($t_fbCreate, 2, $sDBName)     
    DllStructSetData($t_fbCreate, 3, $sUsername)     
    DllStructSetData($t_fbCreate, 4, $sPassword)     
    Local $vRet = DllCall($h_fbDll, "int", "CreateDatabase", "ptr", DllStructGetPtr($t_fbCreate, 1), "ptr", DllStructGetPtr($t_fbCreate, 2), "ptr", DllStructGetPtr($t_fbCreate, 3), "ptr", DllStructGetPtr($t_fbCreate, 4), "int", $iWriteMode, "int", $iDialect)     $t_fbCreate = 0     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_CreateDatabase 
; #FUNCTION# =====================================================================
; Name ..........: _FireBird_SetPageBuffers 
; Description ...: Sets the page buffers when creating a database. 
; Syntax ........: _FireBird_SetPageBuffers($a) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $iSize - IN - 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================ 
Func _FireBird_SetPageBuffers($h_fbDll, $iSize)     
    Local $vRet = DllCall($h_fbDll, "int", "SetPageBuffers", "int", $iSize)     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_SetPageBuffers 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_ConnectDatabase 
; Description ...: Connect to an embeded database. 
; Syntax ........: _FireBird_ConnectDatabase($sDBName, $sUsername, $sPassword) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $sDBName - IN - 
;                  $sUsername - IN - 
;                  $sPassword - IN - 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: Only dialect 3 database supported 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================ 
Func _FireBird_ConnectEmbededDatabase($h_fbDll, $sDBName, $sUsername, $sPassword)     
    Local $tagfbCreate = "char[%d];char[%d];char[%d]"     
    $tagfbCreate = StringFormat($tagfbCreate, StringLen($sDBName) + 1, StringLen($sUsername) + 1, StringLen($sPassword) + 1)     
    Local $t_fbCreate = DllStructCreate($tagfbCreate)     
    DllStructSetData($t_fbCreate, 1, $sDBName)     
    DllStructSetData($t_fbCreate, 2, $sUsername)     
    DllStructSetData($t_fbCreate, 3, $sPassword)     
    Local $vRet = DllCall($h_fbDll, "int", "ConnectDatabase", "ptr", DllStructGetPtr($t_fbCreate, 1), "ptr", DllStructGetPtr($t_fbCreate, 2), "ptr", DllStructGetPtr($t_fbCreate, 3))     
    $t_fbCreate = 0     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_ConnectEmbededDatabase 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_ConnectDatabase 
; Description ...: Connect to a database. ; Syntax ........: _FireBird_ConnectDatabase($sDBName, $sUsername, $sPassword) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $sServerName - IN - 
;                  $sDBName - IN -
;                  $sUsername - IN - 
;                  $sPassword - IN - 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......:
; Remarks .......: Only dialect 3 database supported 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================ 
Func _FireBird_ConnectDatabase($h_fbDll, $sServerName, $sDBName, $sUsername, $sPassword)     
    Local $tagfbCreate = "char[%d];char[%d];char[%d];char[%d]"    
    $tagfbCreate = StringFormat($tagfbCreate, StringLen($sServerName) + 1, StringLen($sDBName) + 1, StringLen($sUsername) + 1, StringLen($sPassword) + 1)     
    Local $t_fbCreate = DllStructCreate($tagfbCreate)     
    DllStructSetData($t_fbCreate, 1, $sServerName)     
    DllStructSetData($t_fbCreate, 2, $sDBName)    
    DllStructSetData($t_fbCreate, 3, $sUsername)     
    DllStructSetData($t_fbCreate, 4, $sPassword)     
    Local $vRet = DllCall($h_fbDll, "int", "ConnectDatabase", "ptr", DllStructGetPtr($t_fbCreate, 1), "ptr", DllStructGetPtr($t_fbCreate, 2), "ptr", DllStructGetPtr($t_fbCreate, 3), "ptr", DllStructGetPtr($t_fbCreate, 4))
    $t_fbCreate = 0     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_ConnectDatabase 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_DisConnectDatabase 
; Description ...: Disconnect from the database 
; Syntax ........: _FireBird_DisConnectDatabase() 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================
Func _FireBird_DisConnectDatabase($h_fbDll)     
    Local $vRet = DllCall($h_fbDll, "int", "DisConnectDatabase")     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_DisConnectDatabase 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_ExecuteBatch 
; Description ...: Do a batch execution of statements 
; Syntax ........: _FireBird_ExecuteBatch($sCmd) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $sCmd - IN - 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================     
Func _FireBird_ExecuteBatch($h_fbDll, $sCmd)     
    Local $t_ExeBatch = DllStructCreate("char[" & StringLen($sCmd) + 1 & "]")     
    DllStructSetData($t_ExeBatch, 1, $sCmd)     
    Local $vRet = DllCall($h_fbDll, "int", "ExecuteBatch", "ptr", DllStructGetPtr($t_ExeBatch))     
    $t_ExeBatch = 0     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_ExecuteBatch 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_ExecuteSelect 
; Description ...: Executes an SQL query. 
; Syntax ........: _FireBird_ExecuteSelect($sCmd, ByRef $sResult) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $sCmd - IN - 
;                  $sResult - IN/OUT - 
; Return values .: Success - Record count 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================     
Func _FireBird_ExecuteSelect($h_fbDll, $sCmd, ByRef $sResult)     
    Local $t_ExeSelect = DllStructCreate("char[" & StringLen($sCmd) + 1 & "];uint;uint")     
    DllStructSetData($t_ExeSelect, 1, $sCmd)     
    Local $vRet = DllCall($h_fbDll, "int", "ExecuteSelect", "ptr", DllStructGetPtr($t_ExeSelect, 1), "ptr", DllStructGetPtr($t_ExeSelect, 2), "ptr", DllStructGetPtr($t_ExeSelect, 3))     
    $sResult = __FireBird_GetBstr(DllStructGetData($t_ExeSelect, 2), DllStructGetData($t_ExeSelect, 3))     
    $t_ExeSelect = 0     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_ExecuteSelect 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_ExecuteStatement 
; Description ...: Execute an SQL statement 
; Syntax ........: _FireBird_ExecuteStatement($sCmd) 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
;                  $sCmd - IN - 
; Return values .: Success - 1 
;                  Failure - 0 and @error to 1 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================     
Func _FireBird_ExecuteStatement($h_fbDll, $sCmd)     
    Local $t_ExeStatement = DllStructCreate("char[" & StringLen($sCmd) + 1 & "]")     
    DllStructSetData($t_ExeStatement, 1, $sCmd)     
    Local $vRet = DllCall($h_fbDll, "int", "ExecuteStatement", "ptr", DllStructGetPtr($t_ExeStatement, 1))     
    $t_ExeStatement = 0     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_ExecuteStatement 
; #FUNCTION# ===================================================================== 
; Name ..........: _FireBird_Help 
; Description ...: Shows help dialog 
; Syntax ........: _FireBird_Help() 
; Parameters ....: $h_fbDll - Handle to firebird dll. 
; Return values .: 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; Example .......: [yes/no] 
; ================================================================================     
Func _FireBird_Help($h_fbDll)     
    Local $vRet = DllCall($h_fbDll, "none", "Help")     
    Return SetError($vRet[0] <> 0, 0, $vRet[0]) 
EndFunc   ;==>_FireBird_Help 
; #INTERNAL_USE_ONLY# ============================================================ 
; Name ..........: __FireBird_GetBstr 
; Description ...: 
; Syntax ........: __FireBird_GetBstr($ptr, $len) 
; Parameters ....: $ptr - IN - 
;                  $len - IN - 
; Return values .: 
; Author ........: Stephen Podhajecki (eltorro) 
; Modified.......: 
; Remarks .......: 
; Related .......: 
; Link ..........: http://fbdll4vb.sourceforge.net/ 
; ================================================================================     
Func __FireBird_GetBstr($ptr, $len)     
    Local $t_ret = DllStructCreate("char[" & $len & "]", $ptr)     
    Local $vRet = DllStructGetData($t_ret, 1)     
    $t_ret = 0     
    ;ConsoleWrite($vRet)     
    Return $vRet 
EndFunc   ;==>__FireBird_GetBstr