any DataBase with AHK please Plus command line

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

any DataBase with AHK please Plus command line

18 Sep 2017, 07:52

Hi all,

I am searching a lot but not able to settle with anything :crazy:

Till date, I have worked with CSVs for storing and retrieving data, now need DB.

please help me with a DB and a command line DB tool to work with ahk.

working example would be highly appreciated. :clap:

Thank You in advance
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: any DataBase with AHK please Plus command line

18 Sep 2017, 08:03

I would recommend SQlite
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

Re: any DataBase with AHK please Plus command line

19 Sep 2017, 01:39

jNizM wrote:I would recommend SQlite
I will test it, and get back.

Thank You
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

Re: any DataBase with AHK please Plus command line

02 Oct 2017, 04:05

Thanks "jNizM" :clap:

I am happy with sqlite3

I am stuck at a place, how to get the resultset from ahk script. I tried and is successful with only first query not second and third and so on...

I am attaching a sample script, and zip with all the resources to test it.

plz help. thanks in advance.

Zip with sqlite dll exe and test db
https://drive.google.com/open?id=0B3U5e ... k9rcDF5Vk0

Code: Select all

#persistent
#SingleInstance Force

MsgBox % RunWaitOne(".help")
MsgBox % RunWaitOne(".open db.db `n select * from test;")

MsgBox % RunWaitMany(".help")
MsgBox % RunWaitMany(".open db.db `n select * from test;")

RunWaitOne(command) {
    ; WshShell object: http://msdn.microsoft.com/en-us/library/aew9yb99
    shell := ComObjCreate("WScript.Shell")
    ; Execute a single command via cmd.exe
    exec := shell.Exec("sqlite3.exe" " /C " command)
    exec.StdIn.WriteLine(commands)  ; Always exit at the end!
    ; Read and return the command's output
    return exec.StdOut.ReadAll()
}

RunWaitMany(commands) {
    shell := ComObjCreate("WScript.Shell")
    ; Open cmd.exe with echoing of commands disabled
    exec := shell.Exec("sqlite3.exe" " /Q /K echo off")
    ; Send the commands to execute, separated by newline
    exec.StdIn.WriteLine(commands)  ; Always exit at the end!
    ; Read and return the output of all commands
    return exec.StdOut.ReadAll()
}
just me
Posts: 9498
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: any DataBase with AHK please Plus command line

02 Oct 2017, 07:05

I'm not familiar with the WScript.Shell.Exec() method, so there might be other options, but this is working here:

Code: Select all

MsgBox % RunWaitOne(".open db.db`nselect * from test;")

RunWaitOne(command) {
    ; WshShell object: http://msdn.microsoft.com/en-us/library/aew9yb99
    shell := ComObjCreate("WScript.Shell")
    ; Execute a single command via cmd.exe
    exec := shell.Exec("sqlite3.exe")
    exec.StdIn.WriteLine(command . "`n.quit")  ; Always exit at the end!
    ; Read and return the command's output
    return exec.StdOut.ReadAll()
}
Why do you want to use sqlite3.exe in this case?
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

Re: any DataBase with AHK please Plus command line

02 Oct 2017, 23:26

Thanks a lot "just me" & "jNizM"

I was unable to understand in which variables the output was stored from "SQLiteDB_sample.ahk" , spent nearly 4 days to figure out, and totally lost hope, so was trying luck with "sqlite3.exe."

Yday night figured out this:

Code: Select all

ShowTable(Table) {
   Global
   Local ColCount, RowCount, Row

   MsgBox, 262144,%AppName% %A_LineNumber%, % ColCount "|" RowCount "|" Row

   ; GuiControl, -ReDraw, ResultsLV
   LV_Delete()
   Sleep 100
   
   ColCount := LV_GetCount("Column")
   MsgBox, 262144,ColCount %A_LineNumber%, % ColCount

   Loop, %ColCount%
      LV_DeleteCol(1)
   
   MsgBox, 262144,%AppName% %A_LineNumber%, % Table.HasNames
   If (Table.HasNames)
   {
      Loop, % Table.ColumnCount
         {
            LV_InsertCol(A_Index,"", Table.ColumnNames[A_Index])
            MsgBox, 262144,%AppName% %A_LineNumber%, % Table.ColumnNames[A_Index]
         }

      If (Table.HasRows)
      {
         MsgBox, 262144,%AppName% %A_LineNumber%, % Table.RowCount
         
         Loop, % Table.RowCount
         {
            RowCount := LV_Add("", "")
            Table.Next(Row)

            Loop, % Table.ColumnCount
               {
                  LV_Modify(RowCount, "Col" . A_Index, Row[A_Index])
                  List1 .= RowCount "|" " Col" . A_Index "|" Row[A_Index] "`r`n"
               }
               MsgBox, 262144,%AppName% %A_LineNumber%, % List1
         }
      }

      MsgBox, 262144,%AppName% %A_LineNumber%, % Table.ColumnCount
      Loop, % Table.ColumnCount
         LV_ModifyCol(A_Index, "AutoHdr")
   }
   GuiControl, +ReDraw, ResultsLV
}

just me
Posts: 9498
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: any DataBase with AHK please Plus command line

03 Oct 2017, 06:24

Hi ahklearner,

congratulations on finally finding a solution by yourself. If you have further questions, feel free to post them in the SQLite thread (unless they're a related to SQL syntax).

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 117 guests