MariaDB SQL syntax near error paranthesis ')' for python
<p>I am trying to insert some data into my MariaDB using python script.
when I do the following in console it works perfectly.</p>

<pre><code>INSERT INTO `Failure` (`faillure_id`, `testrun_id`, `failed_at`, `log_path`, `node`) 
         VALUES   (2, 1, 'STEP8:RUN:RC=1', '/var/fail_logs','NodeA')
</code></pre>

<p>shows me a query ok. and I can see the table being populated. no problem there.</p>

<p>However when I do the same SQL query using python I get some error.
Here's my code</p>

<pre><code>conn = MySQLdb.connect("localhost","user","","DB")
cursor = conn.cursor()

cursor.execute("""INSERT INTO `Failure` (`testrun_id`, `failed_at`, `log_path`, `node`) VALUES (%s, %s, %s, %s)""",(testrun_id, failed_at, log_path, node))
conn.commit()
</code></pre>

<p>this yields the following error</p>

<blockquote>
  <p>check the manual that corresponds to your MariaDB server version for the right syntax to use near '),</p>
</blockquote>

<p>Can someone please help me understand where the error is coming from. Thanks in advance.</p>

<p>As a work-around I'm building the query string like this </p>

<pre><code>sql_query = "INSERT INTO `Failure` (`testrun_id`, `failed_at`, `log_path`, `node`) VALUES " + "( '" + str(testrun_id) + "', '" + str(failed_at) + "', '"+ log_path + "', '" + node + "')"
cursor.execute(sql_query)
</code></pre>

<p>not very efficient but does the job for now.</p>

python mysql mariadb