Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › SQLite and Cloverleaf
- This topic has 50 replies, 14 voices, and was last updated 6 years, 4 months ago by Max Drown (Infor).
-
CreatorTopic
-
October 11, 2013 at 4:29 pm #53863Max Drown (Infor)Keymaster
Here are some sample scripts and files demonstrating how to use SQLite with Cloverleaf. Online documentation:
http://www.sqlite.org/docs.html andhttp://docs.activestate.com/activetcl/8.5/sqlite/doc/sqlite3.html 01) Create a database. Add this code to a file test.sql and then issue this command from the command line “sqlite test.db < test.sql". This will create a database called test.db. You'll see the database file in the directory. You can re-issue this command each time you want to reinitialize the database (empty the database).
[code]——-- Max Drown (Infor)
-
CreatorTopic
-
AuthorReplies
-
-
October 11, 2013 at 5:15 pm #79256Jim KosloskeyParticipant
Thanks Max!
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
October 11, 2013 at 6:27 pm #79257Paul JohnstonParticipant
Max,
Another recent Clovertech thread discussed SQLite with CL version 6.0 .
I believe it was 5.7 and above when SQLite was bundled with Cloverleaf.
In your sample SQL scripts used with Cloverleaf is it independent of the CL version.
Thanks
-
October 11, 2013 at 6:32 pm #79258Max Drown (Infor)KeymasterPaul Johnston wrote:
Max,
Another recent Clovertech thread discussed SQLite with CL version 6.0 .
I believe it was 5.7 and above when SQLite was bundled with Cloverleaf.
In your sample SQL scripts used with Cloverleaf is it independent of the CL version.
-- Max Drown (Infor)
-
October 15, 2013 at 12:04 pm #79259Paul JohnstonParticipant
Excellent Max. !
Thank you .
-
November 19, 2013 at 6:44 pm #79260Femina JafferParticipant
Thank you Max! This is very helpful.
-
November 28, 2013 at 7:59 pm #79261Gene SalayParticipant
Thanks Max!
One note – the activestate link doesn’t work as is – due to a trialing period included in the link.
To use, copy the link into your browser and delete the period.
-
November 28, 2013 at 8:02 pm #79262Max Drown (Infor)KeymasterGene Salay wrote:
Thanks Max!
One note – the activestate link doesn’t work as is
-- Max Drown (Infor)
-
February 6, 2014 at 10:40 pm #79263Mark ThompsonParticipant
Hi Max,
Is it possible to connect the new database-inbound or database-outbound protocols to sqlite? It so, an example of the Database Configurations tab and Configure Database Drivers… window would be very helpful.
If this is not possible, are there examples somewhere showing how to connect to other types of databases?
- Mark Thompson
HealthPartners -
February 6, 2014 at 10:40 pm #79264Max Drown (Infor)Keymaster
Hi, Mark. What version of Cloverleaf are you using?
-- Max Drown (Infor)
-
February 6, 2014 at 10:41 pm #79265Mark ThompsonParticipant
6.0.1
- Mark Thompson
HealthPartners -
February 6, 2014 at 10:42 pm #79266Max Drown (Infor)Keymaster
I’ll upload a BOX. One minute …
-- Max Drown (Infor)
-
February 6, 2014 at 11:07 pm #79267Max Drown (Infor)Keymaster
I’ve attached a BOX with some sqlite and mysql examples to the original post. Please let me know if you have any questions.
-- Max Drown (Infor)
-
February 6, 2014 at 11:34 pm #79268Max Drown (Infor)Keymaster
I can’t get the BOX to upload to the forum. Here’s a download link instead.
https://www.dropbox.com/s/d65vwh80hy10bbc/db_examples_cis60.zip?dl=0
https://www.dropbox.com/s/egxuv6uaql734dc/db_examples_cis612.zip?dl=0
-- Max Drown (Infor)
-
February 7, 2014 at 4:27 pm #79269Mark ThompsonParticipant
Thanks Max. Excellent examples.
- Mark Thompson
HealthPartners -
April 10, 2014 at 7:39 pm #79270James CobaneParticipant
Is there updated documentation regarding the use of the sqlite commands/extensions in lieu of gdbm? The documentation with 5.8 as well as 6.0 still reference the old gdbm extensions. In the release notes there is some brief references to the clsqlite package, but there is no information in the actual documentation.
Any info is appreciated.
Thanks,
Jim Cobane
Henry Ford Health
-
April 10, 2014 at 7:40 pm #79271Max Drown (Infor)Keymaster
James, would you please submit that question via Infor Xtreme? They may need to update the docs and your feedback would be helpful.
-- Max Drown (Infor)
-
April 10, 2014 at 7:46 pm #79272James CobaneParticipant
Will do.
-
July 8, 2014 at 5:16 pm #79273Max Drown (Infor)Keymaster
I added a example database maintenance proc to the original post.
-- Max Drown (Infor)
-
April 28, 2015 at 3:40 pm #79274Kimberly DrewParticipant
Hello – We are updating a sqlite db with specific patient MRNs in the ADT process, which is in 1 site, and then we need to read that db to know if that is a valid patient to send the results and also documents to that receiving system. Both the results and document interfaces are in separate sites. the ADT tclproc will be the only tclproc that will issue the “delete” or “insert” commands, where the other sites will only “select” from the same db to see if that patient exists. Support had mentioned that we could access the db from the other sites by using the full path, but that we needed to be carfeul to program SQLite db lock handling into the scripts. We have been successful in accessing the db from the other sites, but the question is about making proper lock handling that is there. the sqlite databases that we have are only used by that same process, and are updated from a backend command line tcl. this is new to us and would like to know if the Sqlite experts have any useful ideas. thanks
-
April 28, 2015 at 5:34 pm #79275Max Drown (Infor)Keymaster
Kim, so far I have tried to keep my sqlite calls in the same process to avoid locking issue. I have been lucky enough to not need to do much lock handling yet. Are you seeing any lock issues in your processes?
-- Max Drown (Infor)
-
April 28, 2015 at 5:40 pm #79276Kimberly DrewParticipant
No – we haven’t seen any locking issues as of yet, but this is only in our test cloverleaf where there isn’t as much activity as there would be in PROD. we are trying to be proactive.
-
April 28, 2015 at 5:47 pm #79277Max Drown (Infor)Keymaster
Do you have yer code wrapped in catch statements like I do above?
Also, do you have a line like this?
Code:DBCMD timeout 10000
-- Max Drown (Infor)
-
April 28, 2015 at 6:05 pm #79278Kimberly DrewParticipant
no I don’t have the catch or the dbcmd timeout in the code. I have attached the ADT proc and the results proc that i currently have in TEST for your review.
-
April 28, 2015 at 7:24 pm #79279Max Drown (Infor)Keymaster
I would recommend read through the code in this thread. The procs will provide a good solid foundation for error handling. You can then add on to them if you need more for locking.
-- Max Drown (Infor)
-
April 28, 2015 at 7:34 pm #79280Kimberly DrewParticipant
ok thanks
-
April 29, 2015 at 8:03 pm #79281John FrazeeParticipant
Max, I get an error when I try to access the box you linked on this thread. Is it available someplace else I can download it, or can you post a new link, please?
-
April 29, 2015 at 9:24 pm #79282Max Drown (Infor)KeymasterJohn Frazee wrote:
Max, I get an error when I try to access the box you linked on this thread. Is it available someplace else I can download it, or can you post a new link, please?
I updated the link. Please give it another try.
-- Max Drown (Infor)
-
April 30, 2015 at 7:47 pm #79283John FrazeeParticipant
Thanks, Max. FYI…There is also a post on 2/6/14 that has the erroneous link. I think it only got fixed on the original post.
-
April 30, 2015 at 7:49 pm #79284Max Drown (Infor)KeymasterMark Thompson wrote:
Thanks Max.
-- Max Drown (Infor)
-
May 4, 2015 at 3:06 pm #79285Max Drown (Infor)KeymasterKimberly Drew wrote:
Hello –
-- Max Drown (Infor)
-
May 4, 2015 at 3:45 pm #79286Kimberly DrewParticipant
Thanks for the additional update. Last week when you mentioned to me about using the catch and timeout in the tclscript, I also saw this same document within the sqlite documentation that your referring to for locking handling.
-
May 4, 2015 at 3:52 pm #79287Max Drown (Infor)Keymaster
For what it’s worth, when you get into cross-process db access (concurrency), especially with higher message volumes, you may want to consider using a database built for that, like MySQL or PostgreSQL, for better performance and user/access management. However, even in these cases, consider that SQLite is specifically built similar to Cloverleaf in that it will not lose data even in the case of the system crash, because changes are written to the disk and not to memory (making it potentially slower but safer). I.e., it may be worth the loss in speed to gain an improvement in data recovery.
-- Max Drown (Infor)
-
May 5, 2015 at 2:02 pm #79288Bob RichardsonParticipant
Greetings Max,
Running Integrator 6.1.0 on AIX 6.1 TL9 SP04 and Global Monitor 6.1.0
Question: is there documentation available on how to access the SMATDB databases from Tcl? or other language?
We are looking to convert from our current legacy flat files (idx/msg)
to SMATDB. We would like to crank out a tool to replace a home grown message finder script (combo of ksh/perl/awk).
Please post your response.
And, thank you.
-
May 5, 2015 at 3:40 pm #79289Terry KellumParticipant
There is great Doco at:
https://www.sqlite.org/tclsqlite.html
If you want more in-depth information for using SQLite at the command prompt, the tutorial at:
http://www.tutorialspoint.com/sqlite/
is very good.
-
May 5, 2015 at 3:56 pm #79290Bob RichardsonParticipant
Terry, thank you.
We will check out the links.
-
May 5, 2015 at 5:59 pm #79291Max Drown (Infor)Keymaster
The general SQLite documentation posted above should get you what you need. I have a post stickied and a link in my signature about working with SQLite in general including some example scripts.
If you are encrypting the database, then there are some additional steps that need to be taken in SQLite in order to decrypt the database. PM me or email me, and I’ll provide the details for decryption. I am not at liberty to post this information publicly due to the sensitivity of encrypted data,
-- Max Drown (Infor)
-
May 5, 2015 at 7:16 pm #79292Max Drown (Infor)Keymaster
I got this back from R&D,
There is a command line tool
-- Max Drown (Infor)
-
May 6, 2015 at 1:29 pm #79293Bob RichardsonParticipant
Greetings Max,
Is there a complimentary tool to READ these SMATDB files like the old hcismat for the flat file version?
Or do we need to create TCL scripts and code up such a tool?
Looking to provide a means to find/extract data messages behind the scenes versus IDE or Global Monitor – no save options at this time.
(We have Integrator and Global Monitor 6.1.0).
Thanks.
-
May 6, 2015 at 10:12 pm #79294Alice KazinParticipant
We wrote a script to pull out messages from Smat database.
However, the script can’t be used on the current file because Sqllite is not committing changes to smatdb immediately. You might notice that x.smatdb-wal file have a more current date than x.smatdb. When the smatdb-wal gets above a certain size, then the records in smatdb-wal are copied into smatdb. The Smat Database tool can view all records from smatdb and new records from smatdb-wal.
-
May 8, 2015 at 5:13 pm #79295Max Drown (Infor)Keymaster
From R&D,
Currently user has to use hcismatconvert to convert SMAT DB to flat files then use hcismatAR12916 has been submitted to create a SMAT DB command line tool similar to hcismat.
-- Max Drown (Infor)
-
May 8, 2015 at 5:36 pm #79296Alice KazinParticipant
However, hcismatconvert won’t work if the new records aren’t committed to smatdb and are instead in smatdb-wal.
-
May 8, 2015 at 5:44 pm #79297Bob RichardsonParticipant
Thank you Max.
-
May 8, 2015 at 5:54 pm #79298Max Drown (Infor)Keymaster
Alice, please submit that as a request using Infor Xtreme. That’s definitely some we need to think about.
-- Max Drown (Infor)
-
May 8, 2015 at 7:48 pm #79299Alice KazinParticipant
We opened Inclident Ticket 8522462 previously with Infor. It was my understanding that this is the normal behavior for Sqllite.
-
March 22, 2017 at 3:50 am #79300Dustin SayesParticipant
Hello,
I’d like to initialize my database when my fileset-local thread starts up.
By initialize I mean… drop and create….
#Check if the table Exist and drop if it does
set sqldrop “DROP TABLE IF EXISTS mydatabasename.mytablename;”
#Then recreate the table
set sqlcreate “CREATE TABLE mydatabasename.mytablename ( create some rows );
#then run the commands
DBCMD eval $sqldrop
DBCMD eval $sqlcreate
I’ve added this code to the start mode of at tps, and placed the tps on the protocol directory parse. When the thread starts up, the log has an error, that my db is an unknown database, when doing DBCMD eval $sqlcreate.(while the database does exist, with a valid table, that contains data)
My setup is an inbound fileset-local :: xlate vrl -> sql :: database-outbound.
This thread will only run once a month, and each time it runs, I need the DB to be wiped before any new data is written.
My other option is to call a .sql script from the tps.
Is there a better way I should be going about this?
The db file is in the /exec/processes/myprocess dir, so access or permissions should be good – I am not certain why the log reports “unknown database mydatabase while executing “DBCMD eval $sqlcreate””
-
March 22, 2017 at 6:10 am #79301Charlie BursellParticipant
I don’t see where you set DBCMD in the start=up. Am I missing something?
I prefer to put code like this in a namespace. The namespace runs as soon as proc is loaded. Does not wait for start-up
-
March 22, 2017 at 1:34 pm #79302Dustin SayesParticipant
Charlie, what do you mean by name space?
I need this to only run once a month, when the thread timer goes off. The inbound file may contain hundreds of rows, so I don’t want want the DB to be initialized after each message.
switch -exact — $mode {
[code]
switch -exact — $mode { -
March 22, 2017 at 1:55 pm #79303Charlie BursellParticipant
I did not see the open command in previous message.
Your code will work in start-up. I just expressed a preference for doing it in a namespace. If placed outside of any procs in the namespace it would only run when the proc is loaded – thread startup.
I don’t understand the error either without more info. You could simplify by setting db like:
set db database/mydb.db
Since you are running in the process directory. It would be more portable if you changed versions.
If the table you are dropping and recreating is the only table in the DB you could simply delete the file like:
file delete $db
If file exists it will be deleted if not no error.
You can then open the DB and it will be recreated then add your table.
Wish I knew more and could help more
-
March 22, 2017 at 6:15 pm #79304Max Drown (Infor)Keymaster
Have you read through this thread?
http://clovertech.infor.com/viewtopic.php?t=6686
Good starting point.
-- Max Drown (Infor)
-
May 18, 2018 at 5:36 pm #79305Max Drown (Infor)Keymaster
Added some information to the original post about auto-populating primary keys. Thank you Van and Dotty at Bay Health for helping working this out!
-- Max Drown (Infor)
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.