找回密码
 加入
搜索
查看: 2481|回复: 3

[AU3基础] sqlite中.separator \t 怎么解释

[复制链接]
发表于 2010-10-6 16:33:18 | 显示全部楼层 |阅读模式
本帖最后由 liufenglg 于 2010-10-6 16:34 编辑
#include <SQLite.au3>
#include <SQLite.dll.au3>
#include <file.au3>
#include <array.au3>
_SQLite_Startup()
;Filenames
Local $sTsvFile = FileGetShortName(_TempFile(@ScriptDir,"~",".exe"))
Local $sDbFile = FileGetShortName(_TempFile(@ScriptDir,"~",".db"))

;Create Tsv File
FileWriteLine($sTsvFile,"a" & @TAB & "b" & @TAB & "c")
FileWriteLine($sTsvFile,"a1" & @TAB & "b1" & @TAB & "c1")
FileWriteLine($sTsvFile,"a2" & @TAB & "b2" & @TAB & "c2")
MsgBox(0,'',FileRead($sTsvFile))
;import (using SQLite3.exe)
Local $sIn,$sOut,$i, $sCreate = "CREATE TABLE TblImport (";
for $i = 1 To _StringCountOccurance(FileReadLine($sTsvFile,1),@TAB) + 1
        $sCreate &= "Column_" & $i & ","
Next
MsgBox(0,'$sCreate',$sCreate)

MsgBox(0,'_StringCountOccurance(FileReadLine($sTsvFile,1),@TAB)',_StringCountOccurance(FileReadLine($sTsvFile,1),@TAB))
$sCreate = StringTrimRight($sCreate,1) & ");"
MsgBox(0,'$sCreate',$sCreate)
$sIn  = $sCreate & @CRLF ; Create Table
$sIn &= ".separator \t" & @CRLF ; Select @TAB as Separator
$sIn &= ".import '" & $sTsvFile & "' TblImport" & @CRLF
MsgBox(0,'$sCreate',$sIn)
_SQLite_SQLiteExe($sDbFile,$sIn,$sOut,-1,true)

If @error = 0 Then
        ;Show Table (using SQLite3.dll)
        Local $iRows,$iColumns,$aRes
        ;_SQLite_Startup()
ConsoleWrite("_SQLite_LibVersion=" &_SQLite_LibVersion() & @CRLF)
        _SQLite_Open($sDbFile)
        _SQLite_GetTable2d(-1,"SELECT ROWID,* FROM TblImport;",$aRes,$iRows,$iColumns)
        _SQLite_Display2DResult($aRes) ; Output to Console
        _ArrayDisplay($aRes)
        _SQLite_Close()
        _SQLite_Shutdown()
Else
        If @error = 2 Then
                ConsoleWrite("ERROR: Sqlite3.exe file not found" & @CRLF)
        Else
                ConsoleWrite("ERROR: @error=" & @error & " when calling _SQLite_SQLiteExe" & @CRLF)
        EndIf
EndIf

;Remove Temp Files
FileDelete($sTsvFile)
FileDelete($sDbFile)

;~ Output:
;~         rowid  Column_1  Column_2  Column_3
;~         1      a         b         c
;~         2      a1        b1        c1
;~         3      a2        b2        c2



Func _StringCountOccurance($sSearchString,$sSubString,$fCaseSense = 0) ; Returns Number of $sSubString in $sSearchString
        Local $iOccCnt = 1
        Do
                If StringInStr($sSearchString,$sSubString,$fCaseSense,$iOccCnt) > 0 Then
                        $iOccCnt += 1
                Else
                        ExitLoop
                EndIf
        Until 0
        Return $iOccCnt - 1
EndFunc
请问这里所用的语句
CREATE TABLE TblImport (Column_1,Column_2,Column_3);
.separator \t         ;分离器 ??
.import 'D:\au3\~hjnutet.txt' TblImport;;;;;;;;;;;;;;导入数据??
  后两行怎么解释啊
 楼主| 发表于 2010-10-9 10:04:42 | 显示全部楼层
自己顶一下
找了些sqlite的帮助没看到对
.separator \t         ;分离器 ??
.import 'D:\au3\~hjnutet.txt' TblImport;;;;;;;;;;;;;;导入数据??
的解析
发表于 2010-10-9 13:22:20 | 显示全部楼层
看帮助里有没有说明,这个没接触到.
 楼主| 发表于 2010-10-10 17:36:23 | 显示全部楼层
看来是沉了?
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 07:24 , Processed in 0.073579 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表