title: Insert into SQL database using Python
body: <p>I want to put a value from my Raspberry Pi into a SQL database on my laptop by using websocket in a Python script.</p>
  
  <pre><code>#starting import MySQLdb
  
  import MySQLdb
  
  # Open database connection
  db = MySQLdb.connect("localhost","root","","cms",autocommit=True)
  
  # prepare a cursor object using cursor() method
  cursor = db.cursor()
  
  from websocket import create_connection
  
  ws = create_connection("ws://192.168.0.53:8080/websocket")
  
  while True:
      result = ws.recv()
      print(result)
      spl = result.split(' ',1)
      boom_id2 = str(spl[0])
      boom_data = str(spl[1])
  
  
  
      sql = """INSERT INTO datain(boom_id2,boom_data)
               # VALUES ('""" + boom_id2 +"""', '""" + boom_data +"""')"""
      cursor.execute(sql)
  
  
  db.close()
  ws.close()
  </code></pre>
  
  <p>It returns an error:</p>
  
  <pre><code>Traceback (most recent call last):
  
    File "C:\Users\Ashraff\Desktop\Enginnering\test.py", line 26, in &lt;module&gt;
      cursor.execute(sql)
    File "C:\Users\Ashraff\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py", line 250, in execute
      self.errorhandler(self, exc, value)
    File "C:\Users\Ashraff\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py", line 50, in defaulterrorhandler
      raise errorvalue
    File "C:\Users\Ashraff\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py", line 247, in execute
      res = self._query(query)
    File "C:\Users\Ashraff\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py", line 411, in _query
      rowcount = self._do_query(q)
    File "C:\Users\Ashraff\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\cursors.py", line 374, in _do_query
      db.query(q)
    File "C:\Users\Ashraff\AppData\Local\Programs\Python\Python36\lib\site-packages\MySQLdb\connections.py", line 277, in query
      _mysql.connection.query(self, query)
  _mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 2")
  </code></pre>