Jump to content
Sign in to follow this  
Ed_Maximized

SQLite Database Browser

Recommended Posts

I made this program because I needed it for another greater project in where I had to create and to modify sqlite's databases.

The script opens a window in where appear enumerated the tables contained in the database and other windows in where the data of each one of the tables is showed.

To do:

(1)Execution of SQL commands

(2)Queries

(3)Add/Remove/Modify data

Help Needed:

-I need to know how to extract the table structure (data types) in order to perform to do number 3.

#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.2.2.0
 Author:         Edmundo Fasano "Ed_Maximized"

 Script Function:
    SQLite Browser

#ce ----------------------------------------------------------------------------

; Script Start
#include <sqlite.au3>
#include <GUIConstants.au3>
Dim $sOut,$Form[10],$ListView[10];,$Tables[10]

$DBName=FileOpenDialog("Seleccione una base de datos",@ScriptDir,"todas (*.*)")
$sIn  = ".headers on"& @CRLF &"select tbl_name from sqlite_master;"&@CRLF
_SQLite_SQLiteExe($DBName,$sIn,$sOut,@ScriptDir&"\sqlite3.exe")
$Tables = StringSplit($sOut, @CRLF, 1)
$Form[0] = GUICreate("Database: "&_GetFileName($DBName), 300, 100, 100, 100)
$ListView[0] = GUICtrlCreateListView($Tables[1], 1, 1, 298, 98)
GUISetState(@SW_SHOW)
For $i=2 To $Tables[0]
    GUICtrlCreateListViewItem($Tables[$i],$ListView[0])
Next
For $ii=2 To $Tables[0]-1
    $sIn  = ".headers on"& @CRLF &"select * from "&$Tables[$ii]&" sqlite_master;"&@CRLF
    _SQLite_SQLiteExe($DBName,$sIn,$sOut,@ScriptDir&"\sqlite3.exe")
    $array  = StringSplit($sOut, @CRLF, 1)
    $Form[$ii] = GUICreate("Table: "&$Tables[$ii], 640, 400, 100+50*($ii-1), 100+50*($ii-1))
    $ListView[$ii] = GUICtrlCreateListView($array[1], 1, 1, 638, 398)
    GUISetState(@SW_SHOW)
    For $i=2 To $array[0]
        GUICtrlCreateListViewItem($array[$i],$ListView[$ii])
    Next
Next

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Exit

Func _GetFileName($ipath)
   Dim $drive,$path,$filename,$ext
   _PathSplit($ipath,$drive,$path,$filename,$ext)
   $dir=$drive&$path
   Return $filename&$ext
EndFunc

If you need a table to test... Here is one... documentos.zip

Ed

Share this post


Link to post
Share on other sites

Hey.. Nice start. I can't wait to see the finished code. I have to work with mssql at work and would love to use autoit to read/write and add/edit..

Jim

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  

×
×
  • Create New...