Error: unable to open database file\r\n\r\nDatabase | by "TMS XData REST Server on Linux - Step by Step" Demo

Hello,
I make everthink like it is seen in the Video 1-5.
But result by "http://xy/tms":
{
"value": [
{
"name": "Customer",
"url": "Customer"
}
]
}
and by "http://xy/tms/Cutomer":
{
"error": {
"code": "SQLiteException",
"message": "Error: unable to open database file\r\n\r\nDatabase: /home/headset/xdata/xdata.db"
}
}
Whats can be wrong?
Greetings Dirk

Hello,

Either the database file xdata.db doesn't exist in the location you informed, or you don't have permissions to access it.
If you are running from Apache, make sure the file is accessible for user/group www-data, which is the one Apache uses.

//--yes user/group like this:

headset@faserver:~$ sudo chgrp www-data xdata
headset@faserver:~$

//--rights like this:

headset@faserver:~$ la xdata -l
total 20
-rw-rw-r-- 1 headset www-data 20480 Feb 5 19:37 xdata.db

//--folder check like this:

headset@faserver:/home$ ls
headset
headset@faserver:/home$ cd headset
headset@faserver:~$ ls
PAServer PAServer-22.0 xdata
headset@faserver:~$ cd xdata
headset@faserver:~/xdata$ ls
xdata.db
headset@faserver:~/xdata$

//--the emty database will fill with an emty "Customer table", so the program must connect to the database....

//--the only thing witch is not like the video is way to create the "ConectionModule", because the akt. "TMS Aurelius DBConnection" generate an other code then in the video, I change it like the video:

unit ConnectionModule;

interface

uses
Aurelius.Drivers.Interfaces,
Aurelius.Drivers.SQLite,
System.SysUtils, System.Classes, Aurelius.Comp.Connection;

type
TSQLiteConnection = class(TDataModule)
{AureliusConnection1: TAureliusConnection;}// akt. version make this
private
public
class function CreateConnection: IDBConnection;
class function CreateFactory: IDBConnectionFactory;

end;

var
SQLiteConnection: TSQLiteConnection;

implementation

{%CLASSGROUP 'System.Classes.TPersistent'}

uses
Aurelius.Drivers.Base;

{$R *.dfm}

{ TMyConnectionModule }

class function TSQLiteConnection.CreateConnection: IDBConnection;
var
SQLiteAdp: TSQLiteNativeConnectionAdapter;
begin
{Result := SQLiteConnection.AureliusConnection1.CreateConnection;}// akt. version make this
SQLiteAdp:=TSQLiteNativeConnectionAdapter.Create('/home/headset/xdata/xdata.db');
Result := SQLiteAdp;
end;

class function TSQLiteConnection.CreateFactory: IDBConnectionFactory;
begin
Result := TDBConnectionFactory.Create(
function: IDBConnection
begin
Result := CreateConnection;
end
);
end;

end.


There is not much involved here besides filesystem. I still think it's a permission issue. Do all the folders provide access to www-data, including to list and create files? Probably SQLite needs some temporary files like journal. Also I see the owner of your file is still headset, try to set both owner and group to www-data.

Hello,
I set the user folder (headset) also to the group www-data, then it works.
It's missing in the video. :slight_smile:
Many thanks
Greetings Dirk

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.