public function uploadCsv($file, $tableId, $incremental = false) { $sapi = $this->configuration->getStorageApi(); $table = new Table($sapi, $tableId, $file, 'id', false, ',', '"', $incremental); try { $table->save(true); } catch (ClientException $e) { throw new UserException('Error while uploading data to StorageAPI: ' . $e->getMessage(), $e); } }
public function __construct(Configuration $configuration, $writerId, $tableId) { $this->configuration = $configuration; $storageApi = $this->configuration->getStorageApi(); $sysBucket = $this->configuration->getSysBucketId($writerId); $this->tableId = $tableId; $tableName = $configuration->getWriterTableName($tableId); parent::__construct($storageApi, $sysBucket . '.' . $tableName); }
public function save($data, Sheet $sheet) { $sheetConfig = $sheet->getConfig(); $tmpFilename = $this->writeRawCsv($data, $sheet); $dataProcessor = new DataProcessor($tmpFilename, $sheetConfig); $outFilename = $dataProcessor->process(); $this->configuration->initDataBucket($sheetConfig['db']['table']); $outputTable = $sheetConfig['db']['table']; $tableNameArr = explode('.', $outputTable); if (count($tableNameArr) != 3) { throw new UserException(sprintf("Error in configuration. Wrong tableId format '%s'", $outputTable)); } $table = new Table($this->configuration->getStorageApi(), $outputTable, $outFilename); try { $table->save(true); } catch (ClientException $e) { throw new UserException($e->getMessage(), $e, ['outputTable' => $outputTable, 'sheet' => $sheet->toArray()]); } unlink($tmpFilename); }
public function save($isAsync = false) { parent::save($isAsync); }
public function getIdFromName($name) { return strtolower(Table::removeSpecialChars($name)); }
public function save($isAsync = false) { $profilesArray = array(); foreach ($this->profiles as $profile) { /** @var Profile $profile */ $profilesArray[] = $profile->toArray(); } $this->setFromArray($profilesArray); parent::save(true); }
private function getAccountTable($accountId) { $tableId = $this->getSysBucketId() . '.' . $accountId; $table = new Table($this->storageApi, $tableId, '', 'id', false, ',', '"', true); $table->setHeader(['id', 'name', 'query', 'outputTable', 'incremental', 'primaryKey', 'enabled']); return $table; }
public function save($async = false) { $data = array(); /** @var File $file */ foreach ($this->files as $file) { $data[] = $file->toArray(); } $this->setFromArray($data); parent::save($async); }
public function save($isAsync = false) { // Sheets toArray $sheetArray = array(); foreach ($this->sheets as $sheet) { /** @var Sheet $sheet */ $sheetArray[] = $sheet->toArray(); } $this->setFromArray($sheetArray); parent::save($isAsync); }
public function testRunOracle() { $writerData = $this->prepareConfig('oracle'); $testing = $this->container->getParameter('testing'); $this->configuration->updateTable($this->writerId, $testing['table']['id'], ['dbName' => 'keboola.dummy']); $dbParams = $testing['oracle']['db']; $dbString = '//' . $dbParams['host'] . ':' . $dbParams['port'] . '/' . $dbParams['database']; $conn = oci_connect($dbParams['user'], $dbParams['password'], $dbString, 'AL32UTF8'); try { oci_execute("DROP TABLE keboola.dummy"); } catch (\Exception $e) { // table doesn't exist } $this->write($writerData['id']); $stid = oci_parse($conn, "SELECT * FROM keboola.dummy"); oci_execute($stid); $result = []; while ($res = oci_fetch_assoc($stid)) { $result[] = array_values($res); } $sapiData = $this->storageApi->exportTable($testing['table']['id']); $sapiDataArr = Table::csvStringToArray($sapiData); $sapiDataArrFinal = []; unset($sapiDataArr[0]); foreach ($sapiDataArr as $row) { unset($row[3]); $sapiDataArrFinal[] = array_values($row); } $this->assertEquals($sapiDataArrFinal, $result); }