I am going to answer my own question because I solved it by myself. We're going to use json response using cursor function. I don't want to use sqlAlchemy for its being complicated and has a speed issue in heavy data posting. I think RequestParser() is not an efficient way for multiple post using arrays. Now here is the code.
class Logs_api(Resource):
@jwt_required
def post(self):
try:
conn = None
#getting the json request of post data
json_dict = request.get_json(force=True, silent=True)
#count the length of json dictionary
x = len(json_dict)
tbl_logs = []
for i in chain(range(0, x)):
tbl_logs.append((json_dict[i]['tbluserid'],json_dict[i]['event'],json_dict[i]['current_longitude'],json_dict[i]['current_latitude'],json_dict[i]['end_longitude'],json_dict[i]['end_latitude'],json_dict[i]['gps_accuracy'],json_dict[i]['gps_provider'],json_dict[i]['battery'],json_dict[i]['datetime_log'], ))
conn = psycopg2.connect(database='yourdb', user='dbuser', host='dbhost', password='dbpass', options='-c statement_timeout=1000')
cursor = conn.cursor()
args_str = ','.join(['%s'] * len(tbl_logs))
# print(cursor.mogrify('INSERT INTO tbl_location_logs(tbluserid, event, current_longitude, current_latitude, end_longitude, end_latitude, gps_accuracy, gps_provider, battery, datetime_log) VALUES {}'.format(args_str), tbl_logs).decode('utf8'))
cursor.execute(cursor.mogrify('INSERT INTO tbl_location_logs(tbluserid, event, current_longitude, current_latitude, end_longitude, end_latitude, gps_accuracy, gps_provider, battery, datetime_log) VALUES {}'.format(args_str), tbl_logs).decode('utf8'))
conn.commit()
cursor.close()
return {'status' : 'success', 'message' : 'success'}
except Exception as e:
x = str(e)
x.replace('\n', '')
return {'status' : 'failed', 'message' : str(x)}
finally:
if conn is not None:
conn.close()
in postman, use raw not x-www-form-urlencoded and type your json there. This is my sample format.
[
{
"tbluserid": "2",
"event": "sample",
"current_longitude": "20",
"current_latitude": "200",
"end_longitude": "20",
"end_latitude": "200",
"gps_accuracy": "200",
"gps_provider": "google maps pangett",
"battery": "200",
"datetime_log": "2018-02-02 23:00:00"
}
]
with the help of the code structure above, i posted a total of 5800+ of data in just 1.2 seconds and the proof are the 2 pictures below:

