syntax error unexpected character after line continuation character python

character, python, syntax-error

Solution

Your code is all on one line, but you are using a line continuation escape character (`\`). Remove that character:

db.trngl_advertiser_agegroup .insert({'id': row[0],'userid':row[1], 'ageid':row[2], 'age_value':row[3], 'created':row[4],  'modified':row[5]})

You do not need to use such a line continuation trick at all when you break the line inside parenthesis or brackets, you can safely put the statement on multiple lines without it:

db.trngl_advertiser_agegroup .insert({
    'id': row[0],
    'userid':row[1], 
    'ageid':row[2], 
    'age_value':row[3],
    'created':row[4],
    'modified':row[5]
})

Problem

my code is, ``` import MySQLdb import collections from pymongo import Connection from config.MySQLdb import * from config.MongoDB import * from config.SyncTables import * db = MySQLdb.connect(DB_HOST,DB_USR,DB_PWD,DB_NAME) cursor = db.cursor() query = "SELECT * FROM table_name WHERE userid = 1" cursor.execute(query) row = cursor.fetchall() mconn = Connection(MONGODB_HOST,MONGODB_PORT) mdb = mconn[MONGODB_DBNAME] #col = mdb[trngl_advertiser_agegroup] db.trngl_advertiser_agegroup .insert({'id': row[0],'userid':row[1], 'ageid':row[2], 'age_value':row[3], \ 'created':row[4], 'modified':row[5]}) print "after update" ``` but I'm getting this error, ``` triongle@triongle.com [~/download/DataInsertionScript]# python IngestDataToMongo.py File "IngestDataToMongo.py", line 21 db.table_name.insert({'id': row[0],'userid':row[1], 'ageid':row[2], 'age_value':row[3],\ 'created':row[4], 'modified':row[5]}) ^ SyntaxError: unexpected character after line continuation character ``` But I don't see any unexpected character after . So please tell me, why I'm getting this error The error image is,

Original source