
So I am trying to add a new database adaptor(Microsoft SQL Server) in the utopia-php/database(https://github.com/utopia-php/database).
I am having trouble connecting through PDO. I tried this
$dbHost = 'mssql';
$dbPort = '1433';
$dbUser = 'SA';
$dbPass = 'P@ssw0rd';
$pdo = new PDO("mssql:host={$dbHost},port={$dbPort}", $dbUser, $dbPass, MsSql::getPDOAttributes());
and it throws this error
PHP Fatal error: Uncaught PDOException: could not find driver in /usr/src/code/bin/tasks/load.php:217
Stack trace:
#0 /usr/src/code/bin/tasks/load.php(217): PDO->__construct()
#1 {main}
thrown in /usr/src/code/bin/tasks/load.php on line 217
I did a little bit more googling where I found they suggested a bunch of different host like sqlsrv
or dblib
but none of them worked.
I tested it without PDO and I am able to connect to the database successfully
Do you have any solution for me. I am pretty sure the url is wrong but I couldn't find the right one?
Links I referred to

Hi, allow me to look into this and get back to you, what OS are you on? linux?

https://stackoverflow.com/questions/2852748/pdoexception-could-not-find-driver can you try these once?

Hey I am on Windows but the containers are working in WSL
About these, these solutions are a bit different the way utopia has architected. Its say to add something in php.ini file (which does not exists in the repo) So I am kinda confused on how to find the driver

There's a proxy in front of Appwrite

Double check Traefik

I'm pretty sure you can't even ping that container without changing config there.

How do i check that?π

Maybe you need to install the driver via the docker file. For example, there are some extra libraries needed for mongo: https://github.com/utopia-php/database/blob/b592ab1bab9d7412cf5b756fdcdf850c03b1470d/Dockerfile#L73

π I vaguely recall this was a thing when I tried like a year ago when I just joined. I recall v little detail. If I have time today, I'll try and lyk

So after a bit more googling and countless build waiting time, I finally figured it out to install those drivers. I was little bit painful but I think it works ( I got different error to fix so that's a progress)

So For the future readers who are gonna look here to know the solution
you need to install the odbc drivers (https://learn.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15&tabs=alpine18-install%2Calpine17-install%2Cdebian8-install%2Credhat7-13-install%2Crhel7-offline) look for the alpine section
and you need to install the sqlsrv and pdo_sqlsrv drivers https://learn.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15#step-2-install-prerequisites-alpine
Make sure to add them in the docker file

[SOLVED]: Connect to a database through PDO?
Recommended threads
- Relationships restricted to a max depth ...
When I do query like: ``` await _databases.listDocuments( databaseId: AppwriteConfig.DATABASE_ID, collectionId: AppwriteConfig.SERVICES_COLLECTI...
- How can we add more than 8 attributes in...
Hey, when I tried to add attribute in my collection it showed me this Error "The maximum number or size of attributes for this collection has been reached." How...
- implement caching
It it possible to cache response for few minutes? I dont want to create function or implement a whole reverse server just to cache it in somewhere ?
