Sign in to follow this  
Followers 0
GiulioM

How can I insert _SQLite_GetTable2D tables using FileWriteLine?

3 posts in this topic

Hello everybody. I'm working to a passwords container database, and I'd like to show SQLite tables in text files or SplashTextOn windows.

Share this post


Link to post
Share on other sites



_SQLite_GetTable2D returns an array, you can use _FileWriteFromArray or if you want to use FileWriteLine loop through the array and write to the file, below is how _FileWriteFromArray does it

; #FUNCTION# ====================================================================================================================
; Name...........: _FileWriteFromArray
; Description ...: Writes Array records to the specified file.
; Syntax.........: _FileWriteFromArray($File, $a_Array[, $i_Base = 0[, $i_UBound = 0]])
; Parameters ....: $File     - String path of the file to write to, or a file handle returned from FileOpen().
;                  $a_Array  - The array to be written to the file.
;                  $i_Base   - Optional: Start Array index to read, normally set to 0 or 1. Default=0
;                  $i_Ubound - Optional: Set to the last record you want to write to the File. default=0 - whole array.
; Return values .: Success - Returns a 1
;                  Failure - Returns a 0
;                  @Error  - 0 = No error.
;                  |1 = Error opening specified file
;                  |2 = Input is not an Array
;                  |3 = Error writing to file
; Author ........: Jos van der Zande <jdeb at autoitscript dot com>
; Modified.......: Updated for file handles by PsaltyDS at the AutoIt forums.
; Remarks .......: If a string path is provided, the file is overwritten and closed.
;                  To use other write modes, like append or Unicode formats, open the file with FileOpen() first and pass the file handle instead.
;                  If a file handle is passed, the file will still be open after writing.
; Related .......: _FileReadToArray
; Link ..........:
; Example .......: Yes
; ===============================================================================================================================
Func _FileWriteFromArray($File, $a_Array, $i_Base = 0, $i_UBound = 0)
    ; Check if we have a valid array as input
    If Not IsArray($a_Array) Then Return SetError(2, 0, 0)

    ; determine last entry
    Local $last = UBound($a_Array) - 1
    If $i_UBound < 1 Or $i_UBound > $last Then $i_UBound = $last
    If $i_Base < 0 Or $i_Base > $last Then $i_Base = 0

    ; Open output file for overwrite by default, or use input file handle if passed
    Local $hFile
    If IsString($File) Then
        $hFile = FileOpen($File, $FO_OVERWRITE)
    Else
        $hFile = $File
    EndIf
    If $hFile = -1 Then Return SetError(1, 0, 0)

    ; Write array data to file
    Local $ErrorSav = 0
    For $x = $i_Base To $i_UBound
        If FileWrite($hFile, $a_Array[$x] & @CRLF) = 0 Then
            $ErrorSav = 3
            ExitLoop
        EndIf
    Next

    ; Close file only if specified by a string path
    If IsString($File) Then FileClose($hFile)

    ; Return results
    If $ErrorSav Then Return SetError($ErrorSav, 0, 0)
    Return 1
EndFunc   ;==>_FileWriteFromArray

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

I missed this topic, sorry.

You can go with _SQLite_Display2DResult by setting the last parameter ($nReturn) to True. No fancy formatting, but efficient.


This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
Sign in to follow this  
Followers 0