I am running an insert query to add data into my database but I get the following error
"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 '%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s' at line 1")"
I have reviewed the code but unable to determine why
cursor.execute("INSERT IGNORE INTO footballtest(`codmeci` ,`datameci`,`orameci` ,`sezonul` ,`etapa` ,`txtechipa1`,`txtechipa2` ,`scor1` ,`scor2` ,`scorp1` ,`scorp2` ,`codechipa1` ,`codechipa2` ,`cotaa` ,`cotae`,`cotad`,`cotao` ,`cotau` ,`suth` ,`suta` ,`sutht`,`sutat` ,`corh` ,`cora` ,`foulsh` ,`foulsa` ,`yellowh`,`yellowa` ,`ballph`,`ballpa` ,`mgolh` ,`mgola` ,`mgol`) VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"), (row[0],row[1],row[2],row[3],row[4],row[5],row[6],row[7],row[8],row[9],row[10],row[13],row[14],row[16],row[17],row[18],row[19],row[20],row[29],row[30],row[31],row[32],row[33],row[34],row[35],row[36],row[37],row[38],row[39],row[40],row[57],row[58],row[59])
Sometimes taking a large problem and simplifying it can reveal what the problem is. Here is your insert, but using only three columns:
sql = "INSERT IGNORE INTO footballtest(codmeci, datameci, orameci) VALUES (%s,%s,%s)"
cursor.execute(sql, (row[0], row[1], row[2]))
Note carefully that the pattern is:
cursor.execute(<some SQL string>, (some CSV tuple of values to bind))
select b1.blog_id, blog_name, blog_desc, b1.blog_date, blog_author, blog_img, ifnull(count(blog_cmt),0) AS blog_cmt
from blog b1, user_blog b2"
I got a error in this:
Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"' at line 1
Error #1064 means that MySQL can't understand your command. To fix it:
Read the error message. It tells you exactly where in your command
MySQL got confused.
Check the manual. By comparing against what MySQL
expected at that point, the problem is often obvious.
Check for reserved words. If the error occurred on an object identifier, check
that it isn't a reserved word (and, if it is, ensure that it's
properly quoted).
You need to remove the quotes at the end and run your query. Looks like there is a typo, you intended a ; instead.
select b1.blog_id, blog_name, blog_desc, b1.blog_date, blog_author, blog_img, ifnull(count(blog_cmt),0) AS blog_cmt
from blog b1, user_blog b2;
Query to insert text in database is:
INSERT INTO uri VALUES('')
I'm getting follwing Syntax error:
MySql.Data.MySqlClient.MySqlException' occurred in MySql.Data.dll
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'liq" style="font-size:110%;font-family:'Alvi Nastaleeq', 'Nafees Nastaleeq', 'Na' at line 1
change this
title=\"Nasta'liq\"
^-----you have single quote alone here .get rid of it
to
title=\"Nasta liq\"
or
title=\"Nastaliq\"
Hi i am working on scrapy and writing a pipeline and in that i had a query which should write the data in to mysql database
tx.execute("""INSERT INTO example_table (book_name,price)
VALUES (%s,%s)""",
(item['book_name'],
item['price'],)
)
I am getting the following errors two errors below
(1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '))' at line 2")
(1241, 'Operand should contain 1 column(s)')
I dont know whats wrong in this query but i am unable to save the data in to database.
Can any one have a idea of this.
You forgot to add % while executing
x.execute("""INSERT INTO example_table (book_name,price)
VALUES (%s,%s)""",%
(item['book_name'],
item['price'])
)
You have added an additional comma at last remove it. following is the correct statement. Kindly try.
x.execute("""INSERT INTO example_table (book_name,price)
VALUES (%s,%s,%s,%s,%s,%s)""",
(item['book_name'],
item['price'])
)
I'm trying this and for some reason is not working.
I'm suspecting it may be the - but not totally sure.
I have read the mysql manual but does not say how to scape or what exactly this error is about, I mean it does but is confusing..
mysql> LOAD DATA INFILE 'meow-ever.txt' INTO TABLE meow-ever
-> ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-ever' at line 1
You must escape your table name, like that :
LOAD DATA INFILE 'meow-ever.txt' INTO TABLE `meow-eve`
Notice it's not regular quote, I don't remember how you can type it on a qwerty keyboard sorry :)