Python Forum
Python 3 MySQL database insert error
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python 3 MySQL database insert error
#8
creat a backup first
Change the dbinsert function to:
    def dbinsert(self, data_tuple):
        cmd = 'INSERT INTO GPS (signature, latitude, longitude, gpstime, gpsdata,
                         orientationNS, orientationEV, direction, speed, distance)  VALUES ('

        for n, element in enumerate(data_tuple):
            if n > 0:
                cmd = '{}, {}'.format(cmd, element)
            else:
                cmd = '{}{}'.format(cmd, element)
        cmd = '{})'.format(cmd)
        print(cmd)
        self.cursor.execute(sql)
        self.dbconnection.commit()
and try that
Reply


Messages In This Thread
RE: Python 3 MySQL database insert error - by Larz60+ - Aug-01-2017, 06:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Mysql and mysql.connector error lostintime 2 683 Oct-03-2023, 10:25 PM
Last Post: lostintime
  sqlite3 Conn Insert Value Error TylerDunbar 3 749 Sep-04-2023, 06:32 PM
Last Post: deanhystad
  Insert 10gb csv files into sql table via python mg24 2 1,933 Apr-28-2023, 04:14 PM
Last Post: snippsat
  Python Serial: How to read the complete line to insert to MySQL? sylar 1 827 Mar-21-2023, 10:06 PM
Last Post: deanhystad
  python insert blank line in logger mg24 1 2,845 Nov-02-2022, 08:36 AM
Last Post: snippsat
  error 1102 (42000) incorrect database name 's' Anldra12 4 1,712 Jun-08-2022, 09:00 AM
Last Post: Anldra12
  Mysql Syntax error in pymysql ilknurg 4 2,365 May-18-2022, 06:50 AM
Last Post: ibreeden
  Insert a multiple constant value after header in csv file using python shantanu97 1 1,154 Apr-24-2022, 10:04 AM
Last Post: Pedroski55
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,090 Feb-09-2022, 09:55 AM
Last Post: ibreeden
Question Debian 11 Bullseye | Python 3.9.x | pip install mysql-connector-python-rf problems BrandonKastning 4 6,690 Feb-05-2022, 08:25 PM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

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