Databases folder and the files

31 views
Skip to first unread message

Jayadevan M

unread,
Nov 6, 2013, 12:07:50 AM11/6/13
to web...@googlegroups.com
When I add a table in db.py under models, or makes changes to the table definition, web2py creates a file with the name of the table forming part of the name (for example, for the 'post' table, it created 23c22a0e7a25abd01f10b0f47df2166c_post.table). Then it generates SQL based on the content in the .table file and the SQLs and results can be seen in sql.log. Is that how it works?

Is it possible to 'decrypt' the content in the *table files - a few lines from the file read like this -

(dp1
S'testext'
p2
(dp3
S'length'
p4
I32768
sS'unique'
p5
I00
sS'sortable'
p6
I4
sS'sql'
p7
S'TEXT'
p8
sS'notnull'
p9
I00


Niphlod

unread,
Nov 6, 2013, 11:31:24 AM11/6/13
to web...@googlegroups.com
import pickle
table_file = 'applications/theapp/databases/thetablefile.table'
print pickle.load(open(table_file))

it's just a dict holding a key for each field, with as value another dict of attributes of that field.

Jayadevan M

unread,
Nov 6, 2013, 9:40:53 PM11/6/13
to web...@googlegroups.com
Thanks. These files get created by web2py after it compares the objects declared under models  with the objects in the database?


--
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 a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/bXSfSywF4q8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Niphlod

unread,
Nov 7, 2013, 2:22:43 AM11/7/13
to web...@googlegroups.com
they are created after altering the tables on the underlying instance, so if any error is found (i.e. the migration is rolled back) they stay the same.

Jayadevan M

unread,
Nov 7, 2013, 2:36:47 AM11/7/13
to web...@googlegroups.com
OK, so I got it wrong.
I see the actual SQLs and execution output in sql.log. The SQLs which are 'about to be executed' to get the instance in sync with the definitions in tables.py/db.py etc, can I see them somewhere?
 

Niphlod

unread,
Nov 7, 2013, 8:24:06 AM11/7/13
to web...@googlegroups.com
no, unless you do a backup of your files, set fake_migrate=True and check sql.log.
Reply all
Reply to author
Forward
0 new messages