How to insert multiple row in dynamoDb using PHP? - nosql

I have written below Json for insert in dynamodb, but unable to insert. But if I try single element without array it's working fine.
$item = $marshaler->marshalJson('
[
{
"PK":"CATG",
"SK":"NAME#SMART_PHONE",
"TYPE":"CATG",
"ATTR":{
"name":"安いスマートフォン一覧【最安値比較】"
}
},
{
"PK":"CATG#SMART_PHONE",
"SK":"SUBCATG#IPHONE",
"TYPE":"SUBCATG",
"ATTR":{
"name":"IPHONE",
"Compa":"mac",
"uid":123
}
},
{
"PK":"CATG#SMART_PHONE#SUBCATG#IPHONE",
"SK":"PROD#PHONE11",
"TYPE":"PROD",
"ATTR":{
"name":"PHONE11",
"uid":123,
"price":112.02,
"images":[
],
"total":120
}
},
{
"PK":"CATG#SMART_PHONE#SUBCATG#IPHONE",
"SK":"PROD#PHONE7",
"TYPE":"PROD",
"ATTR":{
"name":"PHONE7",
"Compa":"mac",
"uid":124,
"price":102.02,
"images":[
],
"total":80
}
}
]
');
$params = [
'TableName' => $tableName,
'Item' => $item
];
$result = $dynamodb->putItem($params);
After apply this code.
I have got below error
Fatal error: Uncaught InvalidArgumentException: The JSON document must be valid and be an object at its root. in E:\xampp\htdocs\shop\vendor\aws\aws-sdk-php\src\DynamoDb\Marshaler.php:99 Stack trace: #0 E:\xampp\htdocs\shop\item.php(30): Aws\DynamoDb\Marshaler->marshalJson('\r\n [\r\n ...') #1 {main} thrown in E:\xampp\htdocs\shop\vendor\aws\aws-sdk-php\src\DynamoDb\Marshaler.php on line 99
If I insert single row it's working fine. How can I insert bulk row ?

To insert multiple items you have two options:
you can have a loop and repeatedly call the PutItem API for each one
you can break up your collection of items into groups of up to 25 and use the BatchWriteItem API (see docs)
Note that the BatchWriteItem API will still result in 25 WCU being used but it just saves you a bit on the network round-trips, making fewer calls.
The downside of using BatchWriteItem is that you have to manage the grouping of items and then handle the partial successful writes, such that unsuccessful items get re-grouped/re-tried.

Related

Unable to get resonse from import contacts sendgrid API using python

Below is the call I am trying to make -
I used field mapping in below data -
data = {
"file_type": "csv",
"field_mappings": [
"_rf2_T",
"_rf0_T",
"_rf1_T",
"_rf10_T",
"w1_T",
"w45_T",
"w46_T",
"w44_T",
"w2_D",
"w43_T"
]
}
print("--data---",data)
response = sg.client.marketing.contacts.put(
request_body=data
)
#print("--data---",data)
print(response.status_code)
print(response.body)
print(response.headers)
and getting below error
{'errors': [{'field': 'contacts', 'message': 'at least one contact is required'}]}
I am expecting upload url and header from api call

Different settings for sys_log in database and log file

i want to deactivate error logs in the database completely no error, no exception and no warning in the sys_log table in the database. I want to use a log file instead - all logging should happen only in this log file. (TYPO3 9 LTS)
Is there a possibility to achieve this?
Thanks
Peter
It seems only possible with an own ExceptionHandler and overloading the method writeLogEntries() in TYPO3\CMS\Core\Error\AbstractExceptionHandler:
protected function writeLogEntries(\Throwable $exception, $context) {
// snip
if ($this->logger) {
$this->logger->critical($logTitle . ': ' . $logMessage, [
'TYPO3_MODE' => TYPO3_MODE,
'exception' => $exception
]);
}
// Write error message to sys_log table
$this->writeLog($logTitle . ': ' . $logMessage);
}
There is no configuration possibility, every exception is written to log file and database.

Magento 1 order creation with disabled produt via soap API

I'm using Magento 1.7 and I want to create an order via magento SOAP API with "disabled" product in it.
Is it possible?
Code:
// create order
echo "\nI will create the order: ";
$resultOrderCreation = $proxy->call($sessionId,"cart.order",array($shoppingCartId, null, $licenseForOrderCreation));
echo "\nOrder created with code:".$resultOrderCreation."\n";
Here is the error trace:
I will create the order:
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Server] Call to
a member function getId() on a non-object in test2.php:175 Stack
trace:
0 test2.php(175): SoapClient->__call('call', Array)
1 test2.php(175): SoapClient->call('6e2ee08630a720a...', 'cart.order', Array)
2 {main} thrown in test2.php on line 175
You need to change Mage_Sales_Model_Quote_Address_Total_Subtotal::_initItem.
Specifically row with code:
if (!$product || !$product->isVisibleInCatalog()) {
return false;
}
Remove/Customize !$product->isVisibleInCatalog().

No rows present in the request when stream importing into Big Query

I was trying to stream import data into big query using tabledata.insert_all
job_data = {
kind: 'bigquery#tableDataInsertAllRequest',
rows: [
{ json: { column_name: value} }
]
}
response = execute(
api_method: bigquery.tabledata.insert_all,
parameters: {
projectId: config['project_id'],
datasetId: DATASET_ID,
tableId: table_id
},
body_object: job_data
)
But I always get the following error message
Google::APIClient::Request Sending API request post https://www.googleapis.com/bigquery/v2/projects/propane-tribute-90023/datasets/development/tables/api_requests_20150414/insertAll {"User-Agent"=>"My Test App/1.0 google-api-ruby-client/0.8.5 Mac OS X/10.9.5\n (gzip)", "Content-Type"=>"application/json", "Accept-Encoding"=>"gzip", "Authorization"=>"Bearer ya29.VgFYvU2nxGDhWiCdS47XRw0J-7GLenRry0Cd3AA2D1RDzMh5gnf-m85I5GeSr9oNW51OuUb9mdwObg", "Cache-Control"=>"no-store"}
Decompressing gzip encoded response (155 bytes)
Decompressed (261 bytes)
Google::APIClient::Request Result: 400 {"Vary"=>"X-Origin", "Content-Type"=>"application/json; charset=UTF-8", "Date"=>"Wed, 15 Apr 2015 03:14:17 GMT", "Expires"=>"Wed, 15 Apr 2015 03:14:17 GMT", "Cache-Control"=>"private, max-age=0", "X-Content-Type-Options"=>"nosniff", "X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "Server"=>"GSE", "Alternate-Protocol"=>"443:quic,p=0.5", "Transfer-Encoding"=>"chunked"} => {"error"=>{"errors"=>[{"domain"=>"global", "reason"=>"invalid", "message"=>"No rows present in the request.", "locationType"=>"other", "location"=>"rows"}], "code"=>400, "message"=>"No rows present in the request."}}
Does anyone have the same the issue and know how to fix it?
Thanks.
Make sure you are providing appropriate values for all of the column headers present in your table’s schema. Providing separate “json” entries will populate individual rows with the column data you provide. Unless you have already assigned values to the variables named column_name and value, you need to provide those values in the statement following the json declaration.
A sample Ruby syntax for a tabledata.insert_all “rows” operation would look as follows:
body = {
"rows" =>[
{"json" => { "person_id" => 10, "person_name" => "test"}},
{"json" => { "person_id" => 11, "person_name" => "test2"}}
]
}

How to remove collection named 'group'?

I accidentally created a collection named 'group'.
How do I remove it.
When I give the following in the mongo console
db.group.drop()
I get the following error
Fri Jun 7 16:36:39.630 JavaScript execution failed: TypeError: Object function ( parmsObj ){
var ret = this.runCommand( { "group" : this._groupFixParms( parmsObj ) } );
if ( ! ret.ok ){
throw "group command failed: " + tojson( ret );
}
return ret.retval;
} has no method 'drop'
The problem is that group is a method on a database object. So, db.group cannot be used to get the actual collection named group. Instead, use .getCollection():
db.getCollection('group').drop()