Import data from different db

is it possible to connect to databases other than the default one to read and import data into the application? The connection parameters are written by the end user so I can’t define them in the config, thanks

Hi @paskuale,

You should be able to create a DB connection dynamically.

https://www.yiiframework.com/doc/api/2.0/yii-db-connection

Perfect, thanks for reply :slight_smile:

Should I potentially connect to one of these two types of databases, postgres and mssql do I need particular libraries to connect or is connectionString sufficient?

I believe they are supported in Yii 2.0 out of the box.

The guide says:

https://www.yiiframework.com/doc/guide/2.0/en/db-dao

But I’m a bit concerned about the security of your application. Generally speaking, letting the end user specify the source DB directly might be a dangerous and tricky idea. You would have to import data from a DB which you can’t be sure what it’s like.

I’m not sure, but I would rather want to follow a traditional approach: importing data from a CVS file or an Excel sheet.

thanks @softark another quest: I noticed that to use for example postgresql I need to enable the pgsql drivers in the php.ini file
Is there any way to automate this step, without having to manually edit the php.ini file with each installation?