You are not logged in.
Pages: 1
- almost never TSQLRestClientDB, which is just an encapsulation of TSQLRestServerDB
For a stand-alone application, create a TSQLRestClientDB. This particular class will initialize an internal TSQLRestServerDB instance, and you'll have full access to the SQLite3 database in the same process, with no speed penalty.
Content will still be converted to and from JSON, but there will be no delay due to the transmission of the data. Having JSON at hand will enable internal cache - see below - and allow to combine this in-process direct process with other transmission protocols (like named pipes or HTTP).
Maybe you should test brotli or gzip with your json file. Those are also supported in every browser while I guess LZMA cannot be used in any browser.
emk wrote:FastMM4 will "feel" the same under FPC+Win64?
No, FastMM not work correctly with FPC x64 (even with FastMM trunk) and should not be used (FPC_FASTMM4 is disabled by default for SynDprUses.inc )
We try cmem - uses less memory compared to build-in FPC memory manager, but a little slower on multi-thread (at last in my case)
Can you post any further information about the issue(s)?
old good Delphi+Win32 has the most optimizations
FPC is open-source, you can add all of them to it.
Delphi+Win64 doesn't have Sqlite AES encryption and most of the routines are PUREPASCAL.
Routines in PUREPASCAL doesn't need to be slower than some ancient asm code as the compiler could generate more modern and thus faster code.
FPC+Win64 doesn't have FastMM4
as written above, I'm not sure why it should not work with FPC x64. I'm using it on FPC x64 for linux...
Btw there is also a newer version which might benefit from modern cpus: https://github.com/pleriche/FastMM4/pull/38
Use FPC+Win64, but I'm a little concerned about speed, about not having FastMM4 and other novelties..
Which novelties do you mean? As already said, FPC is open-source and you can add all missing features you might need.
And about speed, I'm pretty sure you won't feel much difference and I think FastMM4 isn't a must-have because it is already some years old and less maintained.
@EgonHugeist
I'd need at least 3 names: libmariadb (windows+linux), libmysql (windows), libmysqlclient (linux)
In linux one could also symlink his exisiting library, e.g. libmysqlclient.so.16
How would I do that without forcing a special name for the library?
Even if I force them to use a special name for the library, how do you know if he uses mysql or mariadb library? Maybe they split more and more and don't work with the same library.
Isn't more a question for the Zeos/ZDBC forum?
I'm not sure as
TSQLDBZEOSConnectionProperties
class is from mORMot
But sure, I can ask there as well...
Hey,
I want to reach that my app only uses libraries which are in an 'external' folder inside my app but how can I load a library only from my app dir with TSQLDBZEOSConnectionProperties?
My actual code looks like this:
TSQLDBZEOSConnectionProperties.Create(TSQLDBZEOSConnectionProperties.URI(dMySQL, server_port), dbname, user, pass);
I know that I can define a library name with the 3rd parameter but how would you do that for MySQL?
Zeos defines
MARIADB_LOCATION = 'libmariadb'+ SharedSuffix;
DLL_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix;
{$IFDEF MSWINDOWS}
WINDOWS_DLL_LOCATION = 'libmysql.dll';
WINDOWS_DLL41_LOCATION = 'libmysql41.dll';
WINDOWS_DLL41_LOCATION_EMBEDDED = 'libmysqld41.dll';
WINDOWS_DLL50_LOCATION = 'libmysql50.dll';
WINDOWS_DLL50_LOCATION_EMBEDDED = 'libmysqld50.dll';
WINDOWS_DLL51_LOCATION = 'libmysql51.dll';
WINDOWS_DLL51_LOCATION_EMBEDDED = 'libmysqld51.dll';
WINDOWS_DLL55_LOCATION = 'libmysql55.dll';
WINDOWS_DLL55_LOCATION_EMBEDDED = 'libmysqld55.dll';
WINDOWS_DLL56_LOCATION = 'libmysql56.dll';
WINDOWS_DLL56_LOCATION_EMBEDDED = 'libmysqld56.dll';
WINDOWS_DLL57_LOCATION = 'libmysql57.dll';
WINDOWS_DLL57_LOCATION_EMBEDDED = 'libmysqld57.dll';
{$ELSE}
LINUX_DLL_LOCATION = 'libmysqlclient'+SharedSuffix;
LINUX_DLL41_LOCATION = 'libmysqlclient'+SharedSuffix+'.14';
LINUX_DLL41_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.14';
LINUX_DLL50_LOCATION = 'libmysqlclient'+SharedSuffix+'.15';
LINUX_DLL50_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.15';
LINUX_DLL51_LOCATION = 'libmysqlclient'+SharedSuffix+'.16';
LINUX_DLL51_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.16';
LINUX_DLL55_LOCATION = 'libmysqlclient'+SharedSuffix+'.18';
LINUX_DLL55_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.18';
LINUX_DLL56_LOCATION = 'libmysqlclient'+SharedSuffix+'.19';
LINUX_DLL56_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.19';
LINUX_DLL57_LOCATION = 'libmysqlclient'+SharedSuffix+'.20';
LINUX_DLL57_LOCATION_EMBEDDED = 'libmysqld'+SharedSuffix+'.20';
{$ENDIF}
and I think the best way of coding would be to use all of those defines, so that someone don't need to maintain a copy of them or force a special name for the library in an app.
MySQL is just an example, the same issue would occur if you try the same with any other database driver from ZEOS...MySQL is just special because of MariaDB+MySQL.
Is it possible to add an option to URI function like
aLoadFromThisLocationOnly: : String= ''
, so it uses default ZEOS defines but only searches in a given path? I'd appreciate it!
Thanks in advance.
Might be useful to add sqlite3_threadsafe function to SynSQLite3, for checking if the used (user) library is compiled in single-thread mode because this will omit the own critical mutexing logic of SQLite. In this case, no multi-thread or serialized use case is possible!
sqlite3_open_v2() could also be called natively with
SQLITE_OPEN_NOMUTEX -> database connection to be in the multi-thread mode
SQLITE_OPEN_FULLMUTEX -> connection to be in serialized mode
if your lib supports it.
--
At the moment, I'm not able to get it working with multiple reader and single writer (special locking used which enables this), if one writes I get an exception as above (library supports multi-threading/serializing).
I tested this with adding a third argument to
fDB := TSQLDatabase.Create(UTF8ToString(Properties.ServerName),Properties.PassWord);
but it does not work either - anything I missed?
@mpv,
any reason why you didn't tried to get it merged into mORMot?
I've created a small application to test the multi-threading but I can't get it to work without errors when writing data.
I create a number of threads for read/write operations as following:
// global variable
C := TSQLDBSQLite3ConnectionProperties.Create('name.db', '', '', '');
// reading thread
Q1 := TQuery.Create(C.ThreadSafeConnection); // does also work flawless with .NewConnection
Q1.SQL.Text := 'SELECT * FROM USERS';
try
Q1.Open;
While not Q1.EOF do
begin
Inc(i); // counts the entries
Q1.Next
end;
Q1.Close;
except on E: Exception do
Writeln(E.Message);
end;
// writing thread
Q1 := TQuery.Create(C.ThreadSafeConnection); // even errors with .NewConnection
Q1.SQL.Text := 'INSERT OR IGNORE INTO USERS (U_NAME) VALUES (:randomname)';
Q1.ParamByName('randomname').AsString := 'username' + IntTostr(RandomRange(0, 4096));
try
Q1.ExecSQL;
except on E: Exception do
Writeln(E.Message);
end;
The errors I get are:
Error SQLITE_BUSY (5) [Step] using 3.25.2 - database is locked, extended_errcode=5
Error SQLITE_BUSY (5) [Step] using 3.25.2 - another row available, extended_errcode=100
TSQLDBSQLite3Statement.Step(SeekFirst=true) not implemented
- When WALMode enabled: (less errors but still sometimes some)
ESQLite3Exception "Error SQLITE_MISUSE (21) [bind_text] using 3.25.2 - another row available, extended_errcode=100" when binding value for parameter "randomname" in "INSERT OR IGNORE INTO USERS (U_NAME) VALUES (:randomname)"
- With C.MainSQLite3DB.Synchronous := smOff; and C.MainSQLite3DB.LockingMode := lmExclusive; (rarely errors)
ESQLite3Exception "Error SQLITE_MISUSE (21) [bind_text] using 3.25.2 - another row available, extended_errcode=100" when binding value for parameter "randomname" in "INSERT OR IGNORE INTO USERS (U_NAME) VALUES (:randomname)"
- With disabled writing threads, concurrent reading works fine
1.
I already did but haven't found any benchmarks which compares TQuery vs. other access.
As I haven't found any examples with using :params with other classes, I assume it's only supported by TQuery.
I think the examples in docs for Variant are not sufficient to answer my question...or not showing it means it does not support it in different order?
4.
Thanks, haven't thought about this but your absolutely right.
1.
Are there any benchmarks for mORMot TQuery vs. direct access (SynDB)? But I don't think that it's really relevant for my application as it'll be in the range of ms I guess.
Is there no way to use ':paramname' in my query instead of '?' and then call bind()?
What about the method with a Variant? The call to the entries must be positioned by order, too?
4.
First time that I hear about the internal cache for prepared statements.
Is it better to use a separate TSQLDBSQLite3ConnectionProperties for each statement (SELECT / INSERT)? As I'll have two or three different SELECTs and one INSERT, only parameters will change.
Hello,
I've started with reading about mORMot and want to start using it in my (old) application. But adapting everything to ORM is quite a huge task, so I want to get rid of my old implementation of a SQLite3 library first in most places as it's buggy since I changed to unicode. Afterwards I'll decide where it makes sense to use ORM and adapt my code for it.
I've searched for some examples which use the SQLite3 from mORMot (SynSQLite3 + SynDBSQLite3) but haven't found anything which is helpful for me.
1.
I'd like to use ':param' in my query and then set the values via ParamByName/FieldByName and afaik only TQuery seems to support it? But I also read that mORMot TQuery is much faster than default Delphi one but I also read that this was changed (lately) and it's slow again now. What's correct? Are there any other ways for simpler use of querys? I only knew about bind/column as an alternative but the syntax is not really easy to read if you have many (5+) values.
Another thing I tested is to use a Variant; I create a TSQLDBStatement with NewThreadSafeStatement before. Seems readable too, what should I prefer?
2.
Using of TSQLDBSQLite3ConnectionProperties is still correct?
Afterwards I use MainSQLite3DB.Execute to create my table.
3.
As I have a multi-thread application, anything I need to take care about? Or is using TQuery or the Variant way with TSQLDBStatement (with NewThreadSafeStatement) enough?
4.
I've seen that your SQLite3 uses an internal lock, why does it use it? Are there any plans to change to the new sqlite _v2 functions which supports passing multi-thread config to it? Or don't use locks if sqlite is compiled in serialized/multi-thread mode? As in those modes, sqlite takes care of locks.
Best Regards,
greedy
Pages: 1