diff --git a/extension/Classes/Core/Database/Database.php b/extension/Classes/Core/Database/Database.php
index 23a5b3add80e8289b5f6832162a62677a45a8af1..a9ff6be46db545fb5b63053eea08aec54b67c271 100644
--- a/extension/Classes/Core/Database/Database.php
+++ b/extension/Classes/Core/Database/Database.php
@@ -74,7 +74,7 @@ class Database {
      * @throws \UserFormException
      * @throws \UserReportException
      */
-    public function __construct($dbIndex = DB_INDEX_DEFAULT) {
+    public function __construct($dbIndex = DB_INDEX_DEFAULT, $config = array()) {
 
         if (empty($dbIndex)) {
             $dbIndex = DB_INDEX_DEFAULT;
@@ -88,6 +88,11 @@ class Database {
         $this->sqlLogAbsolute = Path::absoluteSqlLogFile();
         $dbInit = $storeSystem[SYSTEM_DB_INIT];
 
+        // In case if typo3 database is asked, use given config for credentials instead of system store data.
+        if (count($config) > 1) {
+            $storeSystem = $config;
+        }
+
         $config = $this->getConnectionDetails($dbIndex, $storeSystem);
         $this->dbName = $config[SYSTEM_DB_NAME];
 
diff --git a/extension/Classes/Core/QuickFormQuery.php b/extension/Classes/Core/QuickFormQuery.php
index bdad7dc533096fcf975713669d5224f8a09130e8..276ac7d866321bb0bd86ef3fafe9674229ff5f3f 100644
--- a/extension/Classes/Core/QuickFormQuery.php
+++ b/extension/Classes/Core/QuickFormQuery.php
@@ -175,6 +175,18 @@ class QuickFormQuery {
 
         $this->dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
         $this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
+        $this->dbIndexT3 = $this->dbIndexQfq;
+
+        if (!defined('PHPUNIT_QFQ')) {
+            $t3DbConfig = T3Handler::getTypo3DbConfig($this->dbIndexData, $this->dbIndexQfq,$this->dbIndexT3);
+        }
+        // Create Typo3 db object if config information exist. In case of api, it doesn't exist.
+        if (count($t3DbConfig) > 1 && $this->dbIndexT3 !== 0) {
+            $this->dbArray[$this->dbIndexT3] = new Database($this->dbIndexT3, $t3DbConfig);
+        } else {
+            // Fallback to qfq user credentials. These are used usually for typo3 db.
+            $this->dbArray[$this->dbIndexT3] = new Database($this->dbIndexQfq);
+        }
 
         $this->dbArray[$this->dbIndexData] = new Database($this->dbIndexData);
 
@@ -188,7 +200,7 @@ class QuickFormQuery {
         \UserReportException::$report_bodytext = $t3data[T3DATA_BODYTEXT];
         \UserReportException::$report_header = $t3data[T3DATA_HEADER];
         \UserReportException::$report_pathFileName = $reportPathFileNameFull;
-        \UserReportException::$report_db = $this->dbArray[$this->dbIndexData];
+        \UserReportException::$report_db = $this->dbArray[$this->dbIndexT3];
 
         $this->evaluate = new Evaluate($this->store, $this->dbArray[$this->dbIndexData]);
 
@@ -210,7 +222,7 @@ class QuickFormQuery {
 
         // Create report file if file keyword not found (and auto export is enabled in qfq settings)
         if ($reportPathFileNameFull === null && $t3data[T3DATA_UID] !== 0 && strtolower($this->store->getVar(SYSTEM_REPORT_AS_FILE_AUTO_EXPORT, STORE_SYSTEM)) === 'yes') {
-            $reportPathFileNameFull = ReportAsFile::create_file_from_ttContent($t3data[T3DATA_UID], $this->dbArray[$this->dbIndexData]);
+            $reportPathFileNameFull = ReportAsFile::create_file_from_ttContent($t3data[T3DATA_UID], $this->dbArray[$this->dbIndexT3]);
         }
 
         // Save pathFileName for use in inline editor
@@ -1824,7 +1836,7 @@ class QuickFormQuery {
 
             $tooltip = 'tt-content: uid=' . $this->t3data['uid'] . ', header=' . $this->t3data['header'];
             $html .= $this->buildInlineReport($this->t3data[T3DATA_UID] ?? null,
-                $this->t3data[T3DATA_REPORT_PATH_FILENAME] ?? null, $this->dbArray[$this->dbIndexData],
+                $this->t3data[T3DATA_REPORT_PATH_FILENAME] ?? null, $this->dbArray[$this->dbIndexT3],
                 $bodytext ?? null, null, null, $tooltip);
         }
         $html .= $report->process($this->t3data[T3DATA_BODYTEXT]);
@@ -1938,9 +1950,9 @@ class QuickFormQuery {
         // $bodytextNew = Support::htmlEntityEncodeDecode(MODE_DECODE, $_POST[REPORT_INLINE_BODYTEXT]);
 
         if (intval($isFile) === 1) {
-            ReportAsFile::write_file_uid($uid, $bodytextNew, $this->dbArray[$this->dbIndexData], $headerNew, $subheaderNew);
+            ReportAsFile::write_file_uid($uid, $bodytextNew, $this->dbArray[$this->dbIndexT3], $headerNew, $subheaderNew);
         } else {
-            ReportAsFile::write_tt_content($uid, $this->dbArray[$this->dbIndexData], $bodytextNew, $headerNew, $subheaderNew);
+            ReportAsFile::write_tt_content($uid, $this->dbArray[$this->dbIndexT3], $bodytextNew, $headerNew, $subheaderNew);
         }
         $this->formSpec[F_FORWARD_MODE] = 'auto';
     }
@@ -2467,7 +2479,7 @@ EOF;
         $uid = $this->store::getVar(T3DATA_UID, STORE_SIP);
         $beUser = $this->store::getVar(TYPO3_BE_USER, STORE_SIP);
         $beUserUid = $this->store::getVar(TYPO3_BE_USER_UID, STORE_SIP);
-        $ttContentOld = $this->dbArray[$this->dbIndexData]->getBodyText($uid, false);
+        $ttContentOld = $this->dbArray[$this->dbIndexT3]->getBodyText($uid, false);
         $isFile = $this->store->getVar(REPORT_SAVE_FILE, STORE_SIP . STORE_ZERO, SANITIZE_ALLOW_DIGIT);
 
         // If some of the following values are not given.
@@ -2508,7 +2520,7 @@ EOF;
 
         // Only save history if changes are given
         if (!empty($payload)) {
-            $this->dbArray[$this->dbIndexData]->setHistoryRecord($dataHistory);
+            $this->dbArray[$this->dbIndexT3]->setHistoryRecord($dataHistory);
         }
     }
 
diff --git a/extension/Classes/Core/Report/Report.php b/extension/Classes/Core/Report/Report.php
index f49a37ac434bf6ab41b2d438b6df4be7aeae8c4a..b52fda83cc387284e1a2fe0fe6a182a5092b0d40 100644
--- a/extension/Classes/Core/Report/Report.php
+++ b/extension/Classes/Core/Report/Report.php
@@ -36,6 +36,7 @@ use IMATHUZH\Qfq\Core\Helper\Sanitize;
 use IMATHUZH\Qfq\Core\Helper\Support;
 use IMATHUZH\Qfq\Core\Store\Sip;
 use IMATHUZH\Qfq\Core\Store\Store;
+use IMATHUZH\Qfq\Core\Typo3\T3Handler;
 
 const DEFAULT_QUESTION = 'question';
 const DEFAULT_ICON = 'icon';
@@ -170,11 +171,13 @@ class Report {
 
         // Default should already set in QuickFormQuery() Constructor
         $this->dbIndexData = $this->store->getVar(TOKEN_DB_INDEX, STORE_TYPO3);
+        $this->dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
         if ($this->dbIndexData === false) {
             $this->dbIndexData = DB_INDEX_DEFAULT;
         }
 
         $this->dbArr[$this->dbIndexData] = new Database($this->dbIndexData);
+        $this->dbArr[$this->dbIndexQfq] = new Database($this->dbIndexQfq);
         $this->variables = new Variables($evaluate, $t3data["uid"]);
 
         $this->link = new Link($this->sip, $this->dbIndexData, $phpUnit);
@@ -458,11 +461,18 @@ class Report {
             $bodytextArr = $functionCache[$rcFunctionName];
         } else {
             // Multi DB setup: check for the correct DB
-            if (DB_INDEX_T3 != $this->dbArr[$this->dbIndexData]->getDbIndex()) {
-                // Current DB is wrong: get DB with DB_INDEX_T3
-                $db = new Database(DB_INDEX_T3);
+            $this->dbIndexT3 = $this->dbIndexQfq;
+
+            if (!defined('PHPUNIT_QFQ')) {
+                $t3DbConfig = T3Handler::getTypo3DbConfig($this->dbIndexData, $this->dbIndexQfq,$this->dbIndexT3);
+            }
+
+            // Create Typo3 db object if config information exist. In case of api, it doesn't exist.
+            if (count($t3DbConfig) > 1 && $this->dbIndexT3 !== 0) {
+                $db = new Database($this->dbIndexT3, $t3DbConfig);
             } else {
-                $db = $this->dbArr[$this->dbIndexData];
+                // Fallback to qfq user credentials. These are used usually for typo3 db.
+                $db = $this->dbArr[$this->dbIndexQfq];
             }
 
             $bodytextArr = $db->getBodyText($rcFunctionName);
diff --git a/extension/Classes/Core/Typo3/T3Handler.php b/extension/Classes/Core/Typo3/T3Handler.php
index a32f7e498f24039c621738c3cdcf6b30620dc6f9..e52578fa4f6cbd2125cbcc513bae7299b3aa74f9 100644
--- a/extension/Classes/Core/Typo3/T3Handler.php
+++ b/extension/Classes/Core/Typo3/T3Handler.php
@@ -323,4 +323,39 @@ class T3Handler {
         }
         return $cache;
     }
+
+    /**
+     * Get typo3 database configuration.
+     *
+     * @param int $dbIndexData
+     * @param int $dbIndexQfq
+     * @param int $dbIndexT3
+     * @return array
+     * @throws \UserFormException
+     */
+    public static function getTypo3DbConfig(int $dbIndexData, int $dbIndexQfq, int &$dbIndexT3): array {
+        $config = array();
+        for ($i = 1; $i <= 3; $i++) {
+            if ($dbIndexData !== $i && $dbIndexQfq !== $i) {
+                $dbIndexT3 = $i;
+                continue;
+            }
+        }
+
+        self::t3AutoloadIfNotRunning();
+
+        $configurationManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Configuration\\ConfigurationManager');
+
+        // Same as $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['qfq']
+        if (isset($GLOBALS['TYPO3_CONF_VARS']) && !defined('PHPUNIT_QFQ')) {
+            $configT3 = $configurationManager->getLocalConfiguration();
+            $typo3DbCredentials = $configT3['DB']['Connections']['Default'];
+            $config['DB_' . $dbIndexT3 . '_USER'] = $typo3DbCredentials['user'];
+            $config['DB_' . $dbIndexT3 . '_PASSWORD'] = $typo3DbCredentials['password'];
+            $config['DB_' . $dbIndexT3 . '_SERVER'] = $typo3DbCredentials['host'];
+            $config['DB_' . $dbIndexT3 . '_NAME'] = $typo3DbCredentials['dbname'];
+        }
+
+        return $config;
+    }
 }
\ No newline at end of file