Sample SQL queries in mORMot

I am using Synopse mORMot to access the SQLite database from Delphi 7. I want to establish a connection and query the database directly through SQL without using the ORM (object-relational matching) mORMot functions.

Could you provide code examples that execute SQL queries without relying on ORM functionality for mORMot?

+4
source share
1 answer

In short: it is better to use the SynDB.pas layer on top of SynSQLite3.pas through its SynDBSQLite3.pas classes, as this will allow your code to work in the future with any database accessible through OleDB / ODBC or even direct access (for example, for Oracle).

For example, using the option to store column data:

 procedure Test(Props: TSQLDBConnectionProperties); var Customer: Variant; begin with Props.Execute('select * from Customers where AccountNumber like ?', ['AW000001%'],@Customer) do while Step do assert(Copy(Customer.AccountNumber,1,8)='AW000001'); end; var Props: TSQLDBConnectionProperties; Props := TSQLDBSQLite3ConnectionProperties.Create('databasefile.db3','','',''); try Test(Props); finally Props.Free; end; 

So, for your question, read the mORMot documentation part related to SynDB and all

But with these units there is no 100% direct RAD access. Just some TClientDataSet fillers. This was not their goal: they want quick and direct access to the database, in code, and not through plumbing.

+6
source

Source: https://habr.com/ru/post/1439658/


All Articles