Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8909577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:27:57+00:00 2026-06-15T03:27:57+00:00

my code is, import MySQLdb import collections from pymongo import Connection from config.MySQLdb import

  • 0

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,
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:27:58+00:00Added an answer on June 15, 2026 at 3:27 am

    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]
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code import smtplib from email.mime.text import MIMEText smtpserver = 'smtp.gmail.com'
Here is a the code I have so far: from ConfigParser import * import
The code #!/usr/bin/env python import MySQLdb print Content-Type: text/html print print <html><head><title>Books</title></head> print <body>
#!/usr/bin/env python # -*- coding: utf-8 -*- import MySQLdb conn = MySQLdb.connect('localhost', 'django_user', 'haha123',
code: import urllib,urllib2 url = 'http://www.pythonchallenge.com/pc/def/linkedlist.php' print urllib2.urlopen(url).read() print urllib2.urlopen(url,urllib.urlencode({'nothing':12345})).read() the question I encounter
Code: import com.independentsoft.exchange.Service; import android.app.Activity; import android.os.Bundle; public class ContactsToExchangeActivity extends Activity { @Override
My code: import datetime as dt import scikits.timeseries as ts ts_start_datetime= ts.Date(freq='T',year=2011,month=1,day=1,hour= 0,minute=0) ts_end_datetime
Try this code - import java.io.StringReader; public class StringReaderTest { public static void main(String[]
I have this code: import re def doReplace(toReplace): i = 1 def chapterReplacer(_): result
I have the code: import subprocess , os ffmpeg = "C:\\ffmpeg_10_6_11.exe" inVid = "C:\\test_in.avi"

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.