#!/usr/bin/python

import MySQLdb
import datetime,re


def insert_database(ip,date,text,words,result,runtime):
   # Open database connection
   db = MySQLdb.connect("localhost","root","mysqlpassworD","vec2topic" )
   
   # print()repare a cursor object using cursor() method
   cursor = db.cursor()

   # Prepare SQL query to INSERT a record into the database.
   sql = """INSERT INTO log(ip,date,text,words,result,runtime) VALUES (%s,%s,%s,%s,%s,%s)""" 

   try:
      # Execute the SQL command
      cursor.execute(sql,(ip,date,text,words,result,runtime))
      # Commit your changes in the database
      db.commit()
   except:

      db.rollback()
