Recent

Author Topic: mORMot questions  (Read 3406 times)

hedgehog

  • Full Member
  • ***
  • Posts: 118
mORMot questions
« on: August 17, 2025, 09:51:56 am »
Hi

I start to climb a huge iceberg called a mormoth.
I took one step, but my boots are slipping :)

1. I want to open SQLite3 databases. Is this good enough code?
Code: Pascal  [Select][+][-]
  1. uses mormot.db.sql, mormot.db.sql.sqlite3;
  2.  
  3. procedure SaveInvoices(Props: TSqlDBConnectionProperties);
  4. var
  5.   R: ISqlDBRows;
  6.   ms: TMemoryStream;
  7. begin
  8.   R:= Props.Execute('select * from Records where Customer = ?', ['Bill']);
  9.   while R.Step do
  10.   begin
  11.     ms:= TMemoryStream.Create;
  12.     try
  13.       R.ColumnBlobToStream('Invoice', ms);
  14.       ms.SaveToFile('Invoice'+IntToStr(R['Order'])+'.pdf');
  15.     finally
  16.       ms.Free;
  17.     end;
  18.   end;
  19.   R.ReleaseRows;
  20. end;
  21.  
  22. procedure OpenSQLite3Table(fn: string);
  23. var
  24.   props: TSQLDBSQLite3ConnectionProperties;
  25. begin
  26.   Props := TSQLDBSQLite3ConnectionProperties.Create(fn,'','','');
  27.   try
  28.     SaveInvoices(Props);
  29.   finally
  30.     Props.Free;
  31.   end;
  32. end;  
  33.  

2. Why does a terminal window appear on startup (Win 10 x64 and Lazarus4)

3. The deprecation message is probably incorrect?

af0815

  • Hero Member
  • *****
  • Posts: 1409
Re: mORMot questions
« Reply #1 on: August 17, 2025, 11:12:08 am »
Have you read and executed the installing of the Static Files as mormot Installation Guide says ?
regards
Andreas

hedgehog

  • Full Member
  • ***
  • Posts: 118
Re: mORMot questions
« Reply #2 on: August 18, 2025, 09:32:33 am »
Yes, of course, I installed these files, and everything works. But as I understand, this way of accessing the database is not welcomed in mORMot.
I'm currently concerned about disabling the console window.
Maybe someone can give me some advice?

dseligo

  • Hero Member
  • *****
  • Posts: 1683
Re: mORMot questions
« Reply #3 on: August 18, 2025, 10:24:03 am »
I'm currently concerned about disabling the console window.
Maybe someone can give me some advice?

Check if option 'Win32 gui application (-WG)' is checked in menu Project, Project Options and then under 'Config and Target', 'Target specific options'.
Of course, you can't use Write and WriteLn to print out results (as is used in your screenshot).

hedgehog

  • Full Member
  • ***
  • Posts: 118
Re: mORMot questions
« Reply #4 on: August 18, 2025, 01:15:13 pm »
Hi, dseligo.

Yes, of course, this flag is checked.
The console window started to appear after I added the mORMot2 package to the project dependencies.

dseligo

  • Hero Member
  • *****
  • Posts: 1683
Re: mORMot questions
« Reply #5 on: August 19, 2025, 12:51:20 am »
Hi, dseligo.

Yes, of course, this flag is checked.
The console window started to appear after I added the mORMot2 package to the project dependencies.

I can't replicate this.
I created new project, added mormot2 to required packages, added 'mormot.db.sql, mormot.db.sql.sqlite3' to uses clause and copied your functions. When I run the project I can't see console window.

I attached project, you can test it to see how it behaves on your end.

hedgehog

  • Full Member
  • ***
  • Posts: 118
Re: mORMot questions
« Reply #6 on: August 20, 2025, 11:18:37 am »
Hi

Thank you, you gave me the right idea.
Actually, the console window appears after I added mormot.db.raw.sqlite3.static to uses in the project1.lpr

dseligo

  • Hero Member
  • *****
  • Posts: 1683
Re: mORMot questions
« Reply #7 on: August 25, 2025, 04:11:49 am »
Hi

Thank you, you gave me the right idea.
Actually, the console window appears after I added mormot.db.raw.sqlite3.static to uses in the project1.lpr

I tried to add mormot.db.raw.sqlite3.static to uses in lpr file and I still don't get console window.

 

TinyPortal © 2005-2018