You are not logged in.
Pages: 1
Hello,
I begin using the Mormot framework and my primary interest in it is as a REST server. I read some docs about how to do for Mormot to access external databases (Firebird in this case), including the Mormot manual related, and I created a small test, but it is raising an error when I call 'CreateMissingTables'. The code and the error message generated are at https://gist.github.com/PrometeusRec/c4 … 68732fbd9f
I am using the latest 'Zeos' version and compiling for Delphi 10.3.3
I am trying to fix this basic thing for two days, but I can't understand what is wrong with it. The 'TEST.FDB' database has just two raws but looks like the 'ID' field is not being really created in the 'CreateMissingTables' call, but it thinks that it was, and then the error message raised. Am I missing something for this test work?
Thanks for any help.
Offline
The test table already exists. I created a fresh Firebird database with just one table and two fields only to begin to understand and learn the Mormot framework. I was expecting that the "CreateMissingTables" call create the 'ID' field on that table. However, that is not happening and, according to the error posted, "CreateMissingTables" is trying to read that field, when the error occurs.
Offline
Has the test table a ID column?
CreateMissingTables won't create the ID column.
Because this ID column should be populated with unique ID numbers, which is not handled yet, because it does not make sense for an existing table.
New columns are generated by CreateMissingTables only if they are not primary keys.
Offline
So you have some existing Firebird DB and you want to serve data from it though REST server?
Note that in such case I would skip altogether defining TSQLModel with existing tables and using FB as external DB. Write interface service that would connect to database (with zeos for example), get data as json and return it to client.
Offline
Offline
So you have some existing Firebird DB and you want to serve data from it though REST server?
Note that in such case I would skip altogether defining TSQLModel with existing tables and using FB as external DB. Write interface service that would connect to database (with zeos for example), get data as json and return it to client.
Thank you for the suggestion. I already got my application test working as expected and using the 'standard' way with TSQLModel. I have included in my tests Mormot secure authentication and it worked too, and now I am trying to have it working with SSL. Is there a real advantage for using interface services, like more speed in the JSON response, for instance? I still didn't study this part of Mormot documentation, but anyway I am already glad about the results that I am getting. Mormot framework is the most impressive piece of code for Delphi in this area that I have seen, and I wonder why I didn't hear about it before.
Offline
Thank you AB, I'll take a look at it!
Offline
> Is there a real advantage for using interface services, like more speed in the JSON response, for instance? I still didn't study this part of Mormot
No, speed is same, I say it's easier to maintain. I've started too with SQLModel for existing FB that's used outside of my app and I've transitioned to interface based approach, following sqlmodel proved too restrictive especially since I need data from several tables.
Offline
No, speed is same, I say it's easier to maintain. I've started too with SQLModel for existing FB that's used outside of my app and I've transitioned to interface based approach, following sqlmodel proved too restrictive especially since I need data from several tables.
The applications use the FB database, and now it will be accessed by a mobile application as well. I am really impressed with SQLite 3 performance, and I thought about converting the FB database to it, but I am concerned about SQLite issues with simultaneous writing. I don't know SQLite well, but I am aware of its limitation when dealing with concurrency writings, so I will stick with an external database for while.
I already followed Mormot documentation about SSL, and I am trying to test it using Chrome or Firefox. Despite Chrome not liking my "Dev Certification Authority" and showing it as "Not Secure" (For Firefox it is ok), I am doing simple tests using a browser, and after that build the client-side. After the SLL all set, I am trying accessing the REST API with SSL enabled (the source above was updated):
'https://localhost:8043/root/test/1'
and I am receiving:
{
"errorCode":403,
"errorText":"Authentication Failed: Invalid signature (0)"
}
Googling a little, I found that this message is related to a problem in authenticating. However, I am setting 'aHandleUserAuthentication' to 'false', at first. 'AUTHGROUP' and 'AUTHUSER' tables were created by Mormot when I was testing authenticating without SSL (I guess that they are only used if 'aHandleUserAuthentication' is set to 'true', right?), but I want to have the REST API accessing working with SSL without authentication first, then with it.
After fixing this issue (accessing the REST API through a browser or AJAX client) can the right above input using authentication like this?
'https://localhost:8043/root/test/1?user=User&password=synopse'
Offline
No, the default authentication has a specific signature computed for each URI.
Check the documentation about it.What you can do is use a JWT instead.
Thank you for the prompt answer. I think you are talking about my second question when I try to access the REST API using authentication, but my current test (using SSL) is not using authentication (I did it without SSL and it worked according to documentation), so the signature computed for a URI should not be used in this case, right? What is the cause of the "Authentication Failed: Invalid signature (0)" message?
Offline
Pages: 1