elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Guía rápida para descarga de herramientas gratuitas de seguridad y desinfección


  Mostrar Temas
Páginas: [1]
1  Programación / Scripting / INSERT mysql, python y mysql.connector en: 6 Octubre 2015, 03:52 am
Hola, estoy teniendo unos problemas con este script haaa, estoy intentando escribir un algoritmo que actualice mi sitio web, pero tengo algunos problemas con el insert del mysql, aquí está el código:

Código
  1. #! python3
  2. # Just a test with mysqldb
  3.  
  4. import sys
  5. import mysql.connector
  6. from datetime import date, datetime, timedelta
  7.  
  8. def main():
  9.    db = mysql.connector.connect(user='', password='',
  10.                                 host='localhost',
  11.                                 database='')
  12.    cursor = db.cursor()
  13.  
  14.    now_date = datetime.now().date()
  15.  
  16.    cursor.execute("INSERT INTO games (name, description, url, category_id, category_parent, width, height, image, published, filetype, instructions, date_added, advert_id, highscores, mochi_id, seo_url, submitter)\
  17.        VALUES ('Tesla', 'this is just a description', 'http://juego..swf', 2, 0, 480, 248, 'http://localhsot.jpg', 0, 'swf', 'This are the instructions', %(now_date)s, 1, 1, '', 'some-game', 0)")
  18.  
  19.    db.close()
  20.  
  21. if '__main__' == __name__:
  22.    sys.exit(main())

Pero al correrlo me manda este error:
raise errors.get_exception(packet)
mysql.connector.errors.ProgrammingError: 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 '%(now_date)s, 1, 1, '', 'some-game', 0)' at line 1
Páginas: [1]
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines