Insertion on MySql Table Fails

57 Views Asked by At

Guys I am building an application with web2py and I need to store and query some information from my MySql datababase. I am trying to insert a row in the table search_term. I am following strictly the web2Py DAL and pyDAL documentations.

#my table definition

CREATE TABLE search_term (
 term_id  int(11) NOT NULL AUTO_INCREMENT,
 term varchar(100) NOT NULL,
 lang varchar(10) NOT NULL,
 since_date date DEFAULT NULL,
 until_date date DEFAULT NULL,
 quantity int(11) DEFAULT NULL,
 PRIMARY KEY (term_id)
 );


#in db.py
db = DAL('mysql://myUser:myPassWord@localhost/myDB')

search_term_table = db.define_table('search_term',
            Field('term_id', 'integer'),
            Field('term', 'string', requires=[IS_NOT_EMPTY()]),
            Field('lang', 'string', requires=[IS_NOT_EMPTY()]),
            Field('quantity', 'integer', requires=[IS_NOT_EMPTY()]),
            Field('since_date', 'date', requires=[IS_DATETIME()]),
            Field('until_date', 'date', requires=[IS_DATETIME()]))

#in controller
result = search_term_table.insert(term = "sample", lang = 'en', quantity = 300)

When I am debugging, everything seems to occur well, but when I execute the select * from search_table in MySQL Workbench, to verify if the data was stored, the table is still empty. Am I doing something wrong? Can someone help me? Thanks a lot!!

0

There are 0 best solutions below