You are not logged in.
Pages: 1
Hi, is there any example to use mormot orm with mysql ?
I have a table (lets call it customer table) in mysql database, need to convert this table to customer class.
In the end, I will show list of customers in the grid.
Any similar example for this case?
Offline
Start by taking a look at "SQLite3\Samples\28 - Simple RESTful ORM Server".
It will create a new table according to the TPerson class layout.
But you can access an existing table, if the primary key of this existing table is an integer (as expected by our ORM kernel, and SQLite3).
Just change the
// ODBC driver e.g. from http://ftp.postgresql.org/pub/odbc/versions/msi
aProps := TODBCConnectionProperties.Create('','Driver=PostgreSQL Unicode'+
{$ifdef CPU64}'(x64)'+{$endif}';Database=postgres;'+
'Server=localhost;Port=5432;UID=postgres;Pwd=postgresPassword','','');
into MySQL access.
May be something like (not tested, just written here directly):
// run mysqld + mysqladmin -u root create test
// ODBC 5.3 driver e.g. from https://dev.mysql.com/downloads/connector/odbc
aProps := TODBCConnectionProperties.Create('',
'Driver=MySQL ODBC 5.3 UNICODE Driver;Database=test;'+
'Server=localhost;Port=3306;UID=root;Pwd=','','');
There are several ways to access MySQL.
Benchmark is available in http://blog.synopse.info/post/2014/03/0 … PostgreSQL
See within sample "15 - External DB performance":
// -------- local MySQL 5.6
{$ifdef USELOCALMYSQL}
// run mysqld + mysqladmin -u root create test
// ODBC driver e.g. from https://dev.mysql.com/downloads/connector/odbc
// warning: connector 5.2.6 and 5.3.1 are dead slow in ODBC.FreeHandle()
// seems not to be tied to SynDB: it is visible on ODBC Data Source tool
// -> use ZEOS/ZDBC instead until fixed
Test(TODBCConnectionProperties,'','Driver=MySQL ODBC 5.3 UNICODE Driver;Database=test;'+
'Server=localhost;Port=3306;UID=root;Pwd=','','',' MySQL',false);
{$ifdef USEZEOS}
// direct ZDBC driver needs only libmysql.dll downloaded e.g. from
// http://cdn.mysql.com/Downloads/Connector-C/mysql-connector-c-*-win32.zip
Test(TSQLDBZEOSConnectionProperties,TSQLDBZEOSConnectionProperties.URI(
dMySQL,'localhost:3306'),'test','root','',' MySQL',false);
{$endif}
{$ifdef USEFIREDAC}
{$ifdef CPU64} // 64-bit server installed locally
TADPhysMySQLDriverLink.Create(Application).VendorLib :=
'c:\Program Files\MySQL\MySQL Server 5.6\lib\';
{$endif}
// direct FireDAC driver needs only libmysql.dll
Test(TSQLDBFireDACConnectionProperties,'MySQL?Server=localhost;Port=3306',
'test','root','',' MySQL',false);
{$endif}
{$ifdef USEUNIDAC}
Test(TSQLDBUniDACConnectionProperties,TSQLDBUniDACConnectionProperties.URI(
dMySQL,'localhost:3306'),'test','root','',' MySQL',false);
{$endif}
{$endif}
and... several forum threads in here, e.g.
http://synopse.info/forum/viewtopic.php?id=774
Even if I would never advice to use OleDB over ODBC for MySQL access...
I would recommend using TSQLDBZEOSConnectionProperties and direct libmysql.dll access with Zeos/ZDBC 7.2.
Offline
Pages: 1