Jump to content

Recommended Posts

Posted

Hello All,
After multiple tests and various readings, I can't find a solution and I wonder if it is really feasible. 
As part of my work, I try to process small CSV files like so many small databases in order to extract certain information.
The aim is to be able to select the ones I am interested in and  programming automatically creates the Tables and fills them in for each separate database.
- If I select 1 file, everything works correctly. 
- From a multiple selection of files (a loop that processes each selected file), the 2nd Base or 3,4 etc base is not created at all. 
I have the impression that he only wants to process one base in my program and not several simultaneously.
yet the _SQLite_Close() and _SQLite_Shutdown() functions are indicated at each new processing.

As an example a few lines of code to illustrate my concern:
I have voluntarily chained together the creation of 2 different databases (what my programming does when I have selected several files to process).
- We can see that the 1st Base is well created, but never the following ones :

 

#AutoIt3Wrapper_UseX64=Y ;(Y/N) Use AutoIt3_x64 or Aut2Exe_x64. Default=N
#include <File.au3>
#include <MsgBoxConstants.au3>
#include <SQLite.au3>
#include <SQLite.dll.au3>

; Init sqlite
_SQLite_Startup(@ScriptDir & "\sqlite3_x64.dll", False, 1) ; Load the DLL
If @error Then Exit MsgBox(0, "Error", "Unable to start SQLite, Please verify your DLL")
ConsoleWrite("SQlite version " & _SQLite_LibVersion() & @LF & @LF)

Local $hDskDb = _SQLite_Open()

If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a Database!")
    Exit -1
EndIf

;First Database
msgbox(0,"base 1", $hDskDb);affichage qu'une base est bien créee en mémoire

 _SQLite_Exec($hDskDb, "create table XX (Key, FirstName text, LastName text, Birth text, Death text)")
_SQLite_Exec($hDskDb, "insert into XX values (10, 'Bohr', 'Niels', '1885/10/07', '1962/11/18')")
_SQLite_QueryFinalize($hDskDb)

_SQLite_Close()
_SQLite_Shutdown()

;2nd DataBase

Local $hDB1 = _SQLite_Open()
If @error Then
    MsgBox($MB_SYSTEMMODAL, "SQLite Error", "Can't create a Database!")
EndIf

msgbox(0,"base 2", $hDB1);This  2nd Database ou X Database will be always =  0

_SQLite_Exec($hDB1, "create table TT (key, FirstName text, LastName text, Birth text)")
_SQLite_Exec($hDB1, "insert into TT values (10, 'Bohr', 'Niels', '1885/10/07')")

_SQLite_Close($hDB1)
_SQLite_Shutdown()

 

I don't understand :-(
Thank you in advance for the help you can give me.
Best regards

 

Eric

Posted

You're creating RAM-based databases which are destroyed when you close them.

SQLite is also unloaded when you invoke _SQLite_ShutDown.

So remove those lines (before creating the second DB:

_SQLite_QueryFinalize($hDskDb)

_SQLite_Close()
_SQLite_Shutdown()

Are you sure you don't want persistant (disk-based) DBs?

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)

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
×
×
  • Create New...