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 7614755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T02:29:04+00:00 2026-05-31T02:29:04+00:00

Im running into this error that I can’t work out Im writing some code

  • 0

Im running into this error that I can’t work out
Im writing some code in Python using tkinter interface to transfer data from a text file to sqlite.

first, here is the relevant code:

def submit_data(self):
    self.new_filename = self.file_entry.get()
    self.new_tablename = self.table_entry.get()
    self.new_fieldname = self.field_entry.get().split(',')

    #print(self.new_fieldname)
    self.create_new.destroy()

    from sqlite3 import dbapi2 as sqlite

    con = sqlite.connect(self.new_filename)    
    cur = con.cursor()
    cur.execute('CREATE TABLE ' + self.new_tablename + '(id INTEGER PRIMARY KEY)')
    for field in self.new_fieldname:
        cur.execute('ALTER TABLE ' + self.new_tablename + ' ADD ' + field)

    with open(self.filename, 'r', encoding='latin-1') as self.the_file:    
        status = True
        #_keynumber=1
        while status:
            _row = self._next_line()

            if _row:
                _entry_list = _row.split(',')
                # add space after text line comma for formatting
                _entry_list = ', '.join(_entry_list)
                #print(_entry_list)

                #entries = {'row': _keynumber, 'entry': _entry_list} 
                #row_entry = "INSERT INTO " + self.new_tablename + " VALUES(" + _entry_list + ")"
                cur.execute("INSERT INTO " + self.new_tablename + " VALUES(" + _entry_list + ")")

                #_colrange = range(_colamount)                    

                #_keynumber+=1

            else:
                status = False   

        con.commit()

At the cur.execute(“INSERT INTO ” … line (about 6 lines up) I get this error:
** cur.execute(“INSERT INTO ” + self.new_tablename + ” VALUES(” + _entry_list + “)”)
sqlite3.OperationalError: near “.”: syntax error**

I have changed this around in many different ways. At one time I had the whole “INSERT INTO … VALUES ….” string as a variable and used

cur.execute(*variable*)

when I did it this way the error was the same except “OperationalError: near “.” was “OperationalError: near “of” … and there was no ‘of’ anywhere.

Im really confused and frustrated. Someone break this down for my please??

Thanks
F

the text file lines its reading are set up like this:
A Big Star In Hollywood,Sandra Dickinson

so I had figured that if I use .join() to put a space after the comma then the string would be the equivalent of two VALUES for the INSERT INTO statement.

  • 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-05-31T02:29:05+00:00Added an answer on May 31, 2026 at 2:29 am

    Remove

    _entry_list = ', '.join(_entry_list)
    

    and use

    cur.execute("INSERT INTO " + self.new_tablename + "(" + ",".join(self.new_fieldname) +") VALUES(" + ",".join(("?" for i in xrange(len(_entry_list)))) + ")", _entry_list)
    

    This will parameterize your query and automatically quote all value in _entry_list.

    You still have to manually quote self.new_tablename and self.new_fieldname. This should be before you use them in any sql statements.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep running into this error MemCacheError (Broken pipe): Broken pipe on my Rails
I am building a XML RSS for my page. And running into this error:
I am running into this issue of releasing an already released object but can't
I remember running into this problem when I started using OpenGL in OS X.
I'm currently using Entity Framework and am running into this issue: The relationship between
I have been running into this error for the last 3 or 4 weeks
I'm running into a problem with the following Python 3.2.2 code. The code is
I'm trying to build a website using object-oriented functionality, and running into some issues.
I'm running into some trouble validating uploaded images using the new IValidatabeObject interface in
Running into a problem where on certain servers we get an error that the

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.