-
-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb01d14
commit 7ce308b
Showing
9 changed files
with
1,520 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
unit CustomerEntityU; | ||
|
||
interface | ||
|
||
uses | ||
MVCFramework.ActiveRecord, MVCFramework.Nullables; | ||
|
||
type | ||
[MVCTable('customers')] | ||
TCustomer = class(TMVCActiveRecord) | ||
private | ||
[MVCTableField('id', [foPrimaryKey, foAutoGenerated])] | ||
fID: NullableInt64; | ||
[MVCTableField('code')] | ||
fCode: NullableString; | ||
[MVCTableField('description')] | ||
fCompanyName: NullableString; | ||
[MVCTableField('city')] | ||
fCity: string; | ||
[MVCTableField('last_contact_timestamp')] | ||
fLastContact: NullableTDateTime; | ||
[MVCTableField('rating')] | ||
fRating: NullableInt32; | ||
[MVCTableField('note')] | ||
fNote: string; | ||
public | ||
property ID: NullableInt64 read fID write fID; | ||
property Code: NullableString read fCode write fCode; | ||
property CompanyName: NullableString read fCompanyName write fCompanyName; | ||
property City: string read fCity write fCity; | ||
property LastContact: NullableTDateTime read fLastContact write fLastContact; | ||
property Rating: NullableInt32 read fRating write fRating; | ||
property Note: string read fNote write fNote; | ||
end; | ||
|
||
|
||
implementation | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
program DataPumpSample; | ||
|
||
uses | ||
Vcl.Forms, | ||
MainFormU in 'MainFormU.pas' {MainForm}, | ||
FDConnectionConfigU in 'FDConnectionConfigU.pas', | ||
CustomerEntityU in 'CustomerEntityU.pas'; | ||
|
||
{$R *.res} | ||
|
||
begin | ||
Application.Initialize; | ||
Application.MainFormOnTaskbar := True; | ||
Application.CreateForm(TMainForm, MainForm); | ||
Application.Run; | ||
end. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
unit FDConnectionConfigU; | ||
|
||
interface | ||
|
||
const | ||
CON_DEF_NAME = 'MyConnX'; | ||
|
||
procedure CreateFirebirdPrivateConnDef(AIsPooled: boolean); | ||
procedure CreateInterbasePrivateConnDef(AIsPooled: boolean); | ||
procedure CreateMySQLPrivateConnDef(AIsPooled: boolean); | ||
procedure CreateMSSQLServerPrivateConnDef(AIsPooled: boolean); | ||
procedure CreatePostgresqlPrivateConnDef(AIsPooled: boolean; ConDefName: String = CON_DEF_NAME); | ||
procedure CreateSqlitePrivateConnDef(AIsPooled: boolean; ConDefName: String = CON_DEF_NAME); | ||
|
||
implementation | ||
|
||
uses | ||
System.Classes, | ||
System.IOUtils, | ||
FireDAC.Comp.Client, | ||
FireDAC.Moni.Base, | ||
FireDAC.Moni.FlatFile, | ||
FireDAC.Stan.Intf | ||
; | ||
|
||
|
||
var | ||
gFlatFileMonitor: TFDMoniFlatFileClientLink = nil; | ||
|
||
procedure CreateMySQLPrivateConnDef(AIsPooled: boolean); | ||
var | ||
LParams: TStringList; | ||
begin | ||
{ | ||
docker run --detach --env MARIADB_USER=example-user --env MARIADB_PASSWORD=my_cool_secret --env MARIADB_ROOT_PASSWORD=root -p 3306:3306 mariadb:latest | ||
} | ||
|
||
LParams := TStringList.Create; | ||
try | ||
LParams.Add('Database=activerecorddb'); | ||
LParams.Add('Protocol=TCPIP'); | ||
LParams.Add('Server=localhost'); | ||
LParams.Add('User_Name=root'); | ||
LParams.Add('Password=root'); | ||
LParams.Add('TinyIntFormat=Boolean'); { it's the default } | ||
LParams.Add('CharacterSet=utf8mb4'); // not utf8!! | ||
LParams.Add('MonitorBy=FlatFile'); | ||
if AIsPooled then | ||
begin | ||
LParams.Add('Pooled=True'); | ||
LParams.Add('POOL_MaximumItems=100'); | ||
end | ||
else | ||
begin | ||
LParams.Add('Pooled=False'); | ||
end; | ||
FDManager.AddConnectionDef(CON_DEF_NAME, 'MySQL', LParams); | ||
finally | ||
LParams.Free; | ||
end; | ||
end; | ||
|
||
procedure CreateMSSQLServerPrivateConnDef(AIsPooled: boolean); | ||
var | ||
LParams: TStringList; | ||
begin | ||
{ | ||
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=!SA_password!" -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest | ||
} | ||
|
||
// [ACTIVERECORDB_SQLSERVER] | ||
// Database=activerecorddb | ||
// OSAuthent=Yes | ||
// Server=DANIELETETI\SQLEXPRESS | ||
// DriverID=MSSQL | ||
// | ||
|
||
LParams := TStringList.Create; | ||
try | ||
LParams.Add('Database=activerecorddb'); | ||
LParams.Add('OSAuthent=Yes'); | ||
LParams.Add('Server=DANIELETETI\SQLEXPRESS'); | ||
if AIsPooled then | ||
begin | ||
LParams.Add('Pooled=True'); | ||
LParams.Add('POOL_MaximumItems=100'); | ||
end | ||
else | ||
begin | ||
LParams.Add('Pooled=False'); | ||
end; | ||
FDManager.AddConnectionDef(CON_DEF_NAME, 'MSSQL', LParams); | ||
finally | ||
LParams.Free; | ||
end; | ||
end; | ||
|
||
procedure CreateFirebirdPrivateConnDef(AIsPooled: boolean); | ||
var | ||
LParams: TStringList; | ||
begin | ||
LParams := TStringList.Create; | ||
try | ||
LParams.Add('Database=' + TPath.GetFullPath(TPath.Combine('..\..', | ||
'data\ACTIVERECORDDB.FDB'))); | ||
LParams.Add('Protocol=TCPIP'); | ||
LParams.Add('Server=localhost'); | ||
LParams.Add('User_Name=sysdba'); | ||
LParams.Add('Password=masterkey'); | ||
LParams.Add('CharacterSet=UTF8'); | ||
if AIsPooled then | ||
begin | ||
LParams.Add('Pooled=True'); | ||
LParams.Add('POOL_MaximumItems=100'); | ||
end | ||
else | ||
begin | ||
LParams.Add('Pooled=False'); | ||
end; | ||
FDManager.AddConnectionDef(CON_DEF_NAME, 'FB', LParams); | ||
finally | ||
LParams.Free; | ||
end; | ||
end; | ||
|
||
procedure CreateInterbasePrivateConnDef(AIsPooled: boolean); | ||
var | ||
LParams: TStringList; | ||
begin | ||
LParams := TStringList.Create; | ||
try | ||
LParams.Add('Database=' + TPath.GetFullPath(TPath.Combine('..\..', | ||
'data\ACTIVERECORDDB.IB'))); | ||
LParams.Add('Protocol=TCPIP'); | ||
LParams.Add('Server=localhost'); | ||
LParams.Add('User_Name=sysdba'); | ||
LParams.Add('Password=masterkey'); | ||
LParams.Add('CharacterSet=UTF8'); | ||
if AIsPooled then | ||
begin | ||
LParams.Add('Pooled=True'); | ||
LParams.Add('POOL_MaximumItems=100'); | ||
end | ||
else | ||
begin | ||
LParams.Add('Pooled=False'); | ||
end; | ||
FDManager.AddConnectionDef(CON_DEF_NAME, 'IB', LParams); | ||
finally | ||
LParams.Free; | ||
end; | ||
end; | ||
|
||
procedure CreatePostgresqlPrivateConnDef(AIsPooled: boolean; ConDefName: String); | ||
var | ||
LParams: TStringList; | ||
begin | ||
LParams := TStringList.Create; | ||
try | ||
LParams.Add('Database=activerecorddb'); | ||
LParams.Add('Protocol=TCPIP'); | ||
LParams.Add('Server=localhost'); | ||
LParams.Add('User_Name=postgres'); | ||
LParams.Add('Password=postgres'); | ||
LParams.Add('MonitorBy=FlatFile'); | ||
|
||
// https://quality.embarcadero.com/browse/RSP-19755?jql=text%20~%20%22firedac%20guid%22 | ||
LParams.Add('GUIDEndian=Big'); | ||
if AIsPooled then | ||
begin | ||
LParams.Add('Pooled=True'); | ||
LParams.Add('POOL_MaximumItems=100'); | ||
end | ||
else | ||
begin | ||
LParams.Add('Pooled=False'); | ||
end; | ||
FDManager.AddConnectionDef(ConDefName, 'PG', LParams); | ||
finally | ||
LParams.Free; | ||
end; | ||
end; | ||
|
||
procedure CreateSqlitePrivateConnDef(AIsPooled: Boolean; ConDefName: String); | ||
var | ||
LParams: TStringList; | ||
lFName: string; | ||
begin | ||
LParams := TStringList.Create; | ||
try | ||
lFName := TPath.Combine(TPath.GetDirectoryName(ParamStr(0)), | ||
'..\..\data\activerecorddb.db'); | ||
LParams.Add('Database=' + lFName); | ||
LParams.Add('StringFormat=Unicode'); | ||
if AIsPooled then | ||
begin | ||
LParams.Add('Pooled=True'); | ||
LParams.Add('POOL_MaximumItems=100'); | ||
end | ||
else | ||
begin | ||
LParams.Add('Pooled=False'); | ||
end; | ||
FDManager.AddConnectionDef(ConDefName, 'SQLite', LParams); | ||
finally | ||
LParams.Free; | ||
end; | ||
end; | ||
|
||
initialization | ||
|
||
gFlatFileMonitor := TFDMoniFlatFileClientLink.Create(nil); | ||
gFlatFileMonitor.FileColumns := [tiRefNo, tiTime, tiThreadID, tiClassName, tiObjID, tiMsgText]; | ||
gFlatFileMonitor.EventKinds := [ | ||
ekVendor, ekConnConnect, ekLiveCycle, ekError, ekConnTransact, | ||
ekCmdPrepare, ekCmdExecute, ekCmdDataIn, ekCmdDataOut]; | ||
gFlatFileMonitor.ShowTraces := False; | ||
gFlatFileMonitor.FileAppend := False; | ||
gFlatFileMonitor.FileName := TPath.ChangeExtension(ParamStr(0), '.trace.log'); | ||
gFlatFileMonitor.Tracing := True; | ||
|
||
finalization | ||
|
||
gFlatFileMonitor.Free; | ||
|
||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
object MainForm: TMainForm | ||
Left = 0 | ||
Top = 0 | ||
Caption = 'Data Pump With MVCActiveRecord Sample' | ||
ClientHeight = 64 | ||
ClientWidth = 425 | ||
Color = clBtnFace | ||
Font.Charset = DEFAULT_CHARSET | ||
Font.Color = clWindowText | ||
Font.Height = -12 | ||
Font.Name = 'Segoe UI' | ||
Font.Style = [] | ||
OnCreate = FormCreate | ||
TextHeight = 15 | ||
object Label1: TLabel | ||
Left = 16 | ||
Top = 24 | ||
Width = 211 | ||
Height = 15 | ||
Caption = 'Migrate data from SQLite to PostgreSQL' | ||
end | ||
object btnDataPump: TButton | ||
Left = 336 | ||
Top = 20 | ||
Width = 81 | ||
Height = 25 | ||
Caption = 'Data Pump' | ||
TabOrder = 0 | ||
OnClick = btnDataPumpClick | ||
end | ||
end |
Oops, something went wrong.