SQLite and AHK Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Yana Petrikova

SQLite and AHK

14 Nov 2017, 16:07

Hi

I have 2 sqlite db and im trying to read them using ahk. I did some searches and the results are a horror show. Outdated, pages that are broken, sqlite but for older ahk, just a big load of complete broken bits and pieces of unusable scripts and fragments, including what was posted by just me, usually good working scripts.

I am hopeful that at least one person here have a current working method that a ahk script can read a sqlite db.

Please share what you have that works.
User avatar
Jovannb
Posts: 268
Joined: 17 Jun 2014, 02:44
Location: Austria

Re: SQLite and AHK

14 Nov 2017, 19:03

Hi,

I'm accessing MS-Access-Databases via ADOSQL (thanks VxE!) and it works (very) well.
I'm not sure whether it works with SQLITE but I think it is worth a try https://autohotkey.com/boards/viewtopic.php?t=74.

J.B.
AHK: 1.1.37.01 Ansi, 32-Bit; Win10 22H2 64 bit, german
Yana Petrikova

Re: SQLite and AHK

14 Nov 2017, 19:22

Jovannb wrote:Hi,

I'm accessing MS-Access-Databases via ADOSQL (thanks VxE!) and it works (very) well.
I'm not sure whether it works with SQLITE but I think it is worth a try https://autohotkey.com/boards/viewtopic.php?t=74.

J.B.
thank you, it does not support sqlite.
Yana Petrikova

Re: SQLite and AHK

14 Nov 2017, 20:15

HotKeyIt wrote:AFAIK it does when you install SQLite ODBC drivers: http://www.ch-werner.de/sqliteodbc/
tried that, no luck,
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: SQLite and AHK

15 Nov 2017, 03:52

SQLiteDB does not work for you? What's wrong?
Yana Petrikova

Re: SQLite and AHK

15 Nov 2017, 04:47

just me wrote:SQLiteDB does not work for you? What's wrong?
Oh, the man himself! nice to see you in this thread

I have the dll in the scripts folder and also have my database in the folder, I even renamed my database test.db so I can work with your demo easily.

But once I ran it it updated my db (I have backups).

All I need to do is get ahk to look at my db and show me all data from a table called training and column called makeup and then I will export that to a text file (using fileappened or something).

Such a simple task but I cannot get it done, i cant get it to even show in the gui that is part of the sample script, my query is good because i tested it in bd browser for sqlite just to make sure!

thank you
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: SQLite and AHK  Topic is solved

15 Nov 2017, 04:51

@ Yana Petrikova
consider to login/register an account to speed things up.
Otherwise you've to wait until your postings are reviewed by an admin/moderator.
Again and again and again ...

Happy scripting :thumbup:
just me
Posts: 9453
Joined: 02 Oct 2013, 08:51
Location: Germany

Re: SQLite and AHK

15 Nov 2017, 05:57

As is, the sample script is not designed to run on an existing DB file. The Test.db will be deleted and recreated on each run.

To check whether the class is working with your DB you might try the following script:

Code: Select all

#NoEnv
; #Warn
#SingleInstance force
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1

DBFileName := A_ScriptDir . "\YourFileName" ; <<< insert your DB file name
DB := New SQLiteDB
If !DB.OpenDB(DBFileName) {
   MsgBox, 16, SQLite Error, % "Msg:`t" . DB.ErrorMsg . "`nCode:`t" . DB.ErrorCode
   ExitApp
}

SQL := "SELECT makeup FROM training;" ; <<< check the table and column name
Result := ""
If !DB.GetTable(SQL, Result)
   MsgBox, 16, SQLite Error: GetTable, % "Msg:`t" . DB.ErrorMsg . "`nCode:`t" . DB.ErrorCode
Else
{
   Values := ""
   For Each, Row In Result.Rows
      Values .= Row[1]  . "`n" ; there is only one column
   Gui, Add, Text, xm, % "RowCount: " . Result.RowCount
   Gui, Add, Text, xm, % "ColumnCount: " . Result.ColumnCount
   Gui, Add, Edit, xm w400 r25 vED
   GuiControl, , ED, %Values%
   Gui, Show, , Result
}
DB.CloseDB()
Return

GuiClose:
ExitApp

#Include Class_SQLiteDB.ahk
Yana Petrikova

Re: SQLite and AHK

15 Nov 2017, 06:42

just me wrote:As is, the sample script is not designed to run on an existing DB file. The Test.db will be deleted and recreated on each run.

To check whether the class is working with your DB you might try the following script:

Code: Select all

#NoEnv
; #Warn
#SingleInstance force
SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1

DBFileName := A_ScriptDir . "\YourFileName" ; <<< insert your DB file name
DB := New SQLiteDB
If !DB.OpenDB(DBFileName) {
   MsgBox, 16, SQLite Error, % "Msg:`t" . DB.ErrorMsg . "`nCode:`t" . DB.ErrorCode
   ExitApp
}

SQL := "SELECT makeup FROM training;" ; <<< check the table and column name
Result := ""
If !DB.GetTable(SQL, Result)
   MsgBox, 16, SQLite Error: GetTable, % "Msg:`t" . DB.ErrorMsg . "`nCode:`t" . DB.ErrorCode
Else
{
   Values := ""
   For Each, Row In Result.Rows
      Values .= Row[1]  . "`n" ; there is only one column
   Gui, Add, Text, xm, % "RowCount: " . Result.RowCount
   Gui, Add, Text, xm, % "ColumnCount: " . Result.ColumnCount
   Gui, Add, Edit, xm w400 r25 vED
   GuiControl, , ED, %Values%
   Gui, Show, , Result
}
DB.CloseDB()
Return

GuiClose:
ExitApp

#Include Class_SQLiteDB.ahk
That worked better and easier than I ever imagined. Thanks a lot :bravo:

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AHK_user, Descolada, sharonhuston and 227 guests