source upload

This commit is contained in:
Razor12911
2022-01-17 22:16:47 +02:00
parent 12936d065b
commit 098e8c48de
1778 changed files with 1206749 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
{
Synopse mORMot framework
Sample 02 - Embedded SQLite3 ORM
purpose of this sample is to show embedded SQLite3 database usage:
- a TSampleRecord class is defined in Unit1.pas
- a SQLite3 server is initialized (see TSQLRestServerDB.Create below) and
will work embedded, i.e. not in Client/Server mode here
- the CreateMissingTables method will create all necessary tables in the
SQLite3 database
- the purpose of the form in Unit1.pas is to add a record to the
database; the Time field is filled with the current date and time
- the 'Find a previous message' button show how to perform a basic query
- since the framework use UTF-8 encoding, we use some basic functions for
fast conversion to/from the User Interface; in real applications,
you should better use our SQLite3i18n unit and the corresponding
TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
- note that you didn't need to write any SQL statement, only define a
class and call some methods; even the query was made very easy (just an
obvious WHERE clause to write)
- thanks to the true object oriented modeling of the framework, the same
exact Unit1 is used for both static in-memory database engine, or
with SQLite3 database storage: only the TForm1.Database object creation
instance was modified
- look at the tiny size of the EXE (even with SQLite3 engine embedded), less
than 400KB with LVCL :)
Version 1.0 - January 24, 2010
}
program Project02;
uses
{$I SynDprUses.inc} // use FastMM4 on older Delphi, or set FPC threads
Forms,
SysUtils,
SynCommons,
mORMot,
mORMotSQLite3, SynSQLite3Static,
Unit1 in '..\01 - In Memory ORM\Unit1.pas' {Form1},
SampleData in '..\01 - In Memory ORM\SampleData.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Caption := ' Sample 02 - Embedded SQLite3 ORM';
Form1.Database := TSQLRestServerDB.Create(Form1.Model,
ChangeFileExt(ExeVersion.ProgramFileName,'.db3'));
TSQLRestServerDB(Form1.Database).CreateMissingTables;
Application.Run;
end.

View File

@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<PathDelim Value="\"/>
<General>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<Title Value="Project02"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="LCL"/>
</Item1>
</RequiredPackages>
<Units Count="1">
<Unit0>
<Filename Value="Project02.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="Project02"/>
</Unit0>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="11"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="Project02"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir);..\..\.."/>
<OtherUnitFiles Value="..\..;..\..\.."/>
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<Conditionals Value="if TargetOS='darwin' then
CustomOptions := ' -Cg-';"/>
<Linking>
<Options>
<Win32>
<GraphicApplication Value="True"/>
</Win32>
</Options>
</Linking>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@@ -0,0 +1,57 @@
{
Synopse mORMot framework
Sample 02 - Embedded SQLite3 ORM
purpose of this sample is to show embedded SQLite3 database usage:
- a TSampleRecord class is defined in Unit1.pas
- a SQLite3 server is initialized (see TSQLRestServerDB.Create below) and
will work embedded, i.e. not in Client/Server mode here
- the CreateMissingTables method will create all necessary tables in the
SQLite3 database
- the purpose of the form in Unit1.pas is to add a record to the
database; the Time field is filled with the current date and time
- the 'Find a previous message' button show how to perform a basic query
- since the framework use UTF-8 encoding, we use some basic functions for
fast conversion to/from the User Interface; in real applications,
you should better use our SQLite3i18n unit and the corresponding
TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
- note that you didn't need to write any SQL statement, only define a
class and call some methods; even the query was made very easy (just an
obvious WHERE clause to write)
- thanks to the true object oriented modeling of the framework, the same
exact Unit1 is used for both static in-memory database engine, or
with SQLite3 database storage: only the TForm1.Database object creation
instance was modified
- look at the tiny size of the EXE (even with SQLite3 engine embedded), less
than 400KB with LVCL :)
Version 1.0 - January 24, 2010
}
program Project02;
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Interfaces, // this includes the LCL widgetset
Forms,
SysUtils,
mORMot,
mORMotSQLite3, SynSQLite3Static,
Unit1 in '..\01 - In Memory ORM\Unit1.pas' {Form1},
SampleData in '..\01 - In Memory ORM\SampleData.pas';
{$R *.res}
begin
RequireDerivedFormResource := True;
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Caption := ' Sample 02 - Embedded SQLite3 ORM';
Form1.Database := TSQLRestServerDB.Create(Form1.Model,
ChangeFileExt(paramstr(0),'.db3'));
TSQLRestServerDB(Form1.Database).CreateMissingTables;
Application.Run;
end.