I have a manually built the MySQL table and then use migrate=False in 
Web2py.  I can enter hours use the add_to_table function passing in the 
table_name, the work_date_start and work_date_end show up in this form as 
the datetime picker.  I can choose from this and add the info into the 
table, as they show up correctly in MySQL.  When I try to view the data in 
show_table function these two dates show up as None.  The timestamp field 
time_added_to_table does show the datetime correctly in a format like 
'2017-02-10 19:37:35'.  Any ideas?

Below are the descriptions of MySQL and the Web2py info used.

I manually build tables in MySQL, here's the table using describe 
billable_hours;
+---------------------+-------------+------+-----+-------------------+----------------+
| Field               | Type        | Null | Key | Default           | 
Extra          |
+---------------------+-------------+------+-----+-------------------+----------------+
| id                  | bigint(20)  | NO   | PRI | NULL              | 
auto_increment |
| time_added_to_table | timestamp   | NO   |     | CURRENT_TIMESTAMP 
|                |
| work_date_start     | datetime(6) | YES  |     | NULL              
|                |
| work_date_end       | datetime(6) | YES  |     | NULL              
|                |
| work_details        | text        | YES  |     | NULL              
|                |
| customer_id         | bigint(20)  | YES  | MUL | NULL              
|                |
| billing_state_id    | bigint(20)  | YES  | MUL | NULL              
|                |
+---------------------+-------------+------+-----+-------------------+----------------+
7 rows in set (0.00 sec)

Here's the web2py info in my_models.py:
-----------------------------
db.define_table('billing_notes', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('note', 'string'),  
format='%(note)s', migrate=False)

db.define_table('customers', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('customer', 'string'),  
format='%(customer)s', migrate=False)

db.define_table('billing_states', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('billing_state', 'string'),  
format='%(billing_state)s', migrate=False)

db.define_table('billable_hours', Field('id', 'integer'), 
Field('time_added_to_table', 'datetime', requires=IS_NOT_EMPTY(), 
writable=False, readable=False), Field('work_date_start', 'datetime'), 
Field('work_date_end', 'datetime'), Field('work_details', 'text'), 
Field('customer_id', db.customers, requires=IS_IN_DB(db, "customers.id", 
"%(customer)s")), Field('billing_state_id', db.billing_states, 
requires=IS_IN_DB(db, "billing_states.id", "%(billing_state)s")),  
format='%(work_date_start)s', migrate=False)
-------------------------------------------------------
My controller in default.py is:
def add_to_table():
   table_name=request.vars['tname']
   form = SQLFORM(db[table_name])
   if form.process().accepted:
       response.flash = 'form accepted'
   elif form.errors:
       response.flash = 'form has errors'
   else:
       response.flash = 'please fill out the form'
   return dict(form=form)

def show_table():
    # shows the table's data
    table_name=request.vars['tname']
    response.flash=table_name
    q=db[table_name]['id']>0
    s=db(q)
    rows=s.select()
    #print(rows)
    return dict(rows=rows


-----------------------------------
Thanks!
cd

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to