Python Forum
sqlite3 operational error on insert query
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sqlite3 operational error on insert query
#1
Hi,

I'm having issues with my insert query. I keep getting the error <class 'sqlite3.OperationalError'>

Have tried several things as suggested on Google but nothing works.

My data values are populated in a list throughout my script and is the only way I can plug the values into my query.

The fields numbers and values align; I've tried all strings; I've tried using (sql_formatted,); and lastly [sql_formatted]

If I manually submit the query as one big long string in sqlite browser, it works. It's just this poncy sqlite3 library forcing me to use the (?,?,?....)format that's causing me grief.

For simplicity, I've completely broken it down:

sql_formatted = []
sql_formatted.append("2018-06-26")
sql_formatted.append("my test")
sql_formatted.append("1.0")
sql_formatted.append("runperiod")
sql_formatted.append("Transaction 1")
sql_formatted.append(1.776)
sql_formatted.append(8.803)
sql_formatted.append(15.161)
sql_formatted.append(4.138)
sql_formatted.append(13.999)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append(15.161)
sql_formatted.append(23)
sql_formatted.append(0)
sql_formatted.append(0)
sql_formatted.append('N')

try:

cur.execute("insert into lr_rundata (current_date, test_name, app_version, test_run_period, transaction_name, '\
'sla_status, minimum, average, maximum, std_deviation, percentile80, percentile81, percentile82, percentile83, percentile84, '\
'percentile85, percentile86, percentile87, percentile88, percentile89, percentile90, percentile91, percentile92, percentile93,'\
'percentile94, percentile95, percentile96, percentile97, percentile98, percentile99, pass, fail, stop, deleted) values '\
'(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", sql_formatted)
Any suggestions would be more than welcome!!

Kind regards,
Me
Reply


Messages In This Thread
sqlite3 operational error on insert query - by jonesin1974 - Jun-26-2018, 12:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  sqlite3 Conn Insert Value Error TylerDunbar 3 812 Sep-04-2023, 06:32 PM
Last Post: deanhystad
  Basic SQL query using Py: Inserting or querying sqlite3 database not returning data marlonbown 3 1,461 Nov-08-2022, 07:16 PM
Last Post: marlonbown
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,461 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  pymysql: insert query throws error wardancer84 12 4,772 Jan-28-2022, 06:48 AM
Last Post: wardancer84
  Query Syntax Error hammer 2 1,666 Jan-03-2022, 02:30 PM
Last Post: hammer
  TypeError: sequence item 0: expected str instance, float found Error Query eddywinch82 1 5,234 Sep-04-2021, 09:16 PM
Last Post: eddywinch82
  Error using mariadb select query with form in python? shams 2 2,074 Jul-29-2021, 12:30 PM
Last Post: shams
  sqlite3.OperationalError: near "=": syntax error Maryan 1 5,706 Oct-31-2020, 12:09 AM
Last Post: Maryan
  sqlite3.OperationalError: near "%": syntax error Linuxdesire 2 18,175 Oct-13-2019, 02:54 AM
Last Post: Linuxdesire
  psycopg2 insert error Wonder_women 0 2,703 Jun-10-2019, 11:56 AM
Last Post: Wonder_women

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020