Module Expr Str Import alias Import alias Import alias Assign NameStore Call NameLoad keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str keyword Str FunctionDef arguments args NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr ListLoad Str BinOpMod Str NameLoad BinOpMod Str NameLoad Str NameLoad keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr Assign NameStore ListComp Call AttributeLoad NameLoad attr Str Str NameLoad comprehension NameStore SubscriptLoad Call AttributeLoad NameLoad attr Slice Num Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad NameLoad Assign NameStore ListLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr ListLoad Str BinOpMod Str NameLoad BinOpMod Str NameLoad Str Str NameLoad NameLoad keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr keyword AttributeLoad NameLoad attr Assign TupleStore NameStore NameStore Call AttributeLoad NameLoad attr If CompareIn Str NameLoad body Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call NameLoad Lambda arguments args NameParam defaults UnaryOpNot BoolOpOr CompareIn NameLoad TupleLoad Str Str CompareIn SubscriptLoad NameLoad Slice Num TupleLoad Str Str NameLoad Assign NameStore Str Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr Str SubscriptLoad NameLoad Index Num attr Num Assign NameStore ListLoad For NameStore SubscriptLoad NameLoad Slice Num Num body If BoolOpOr Call AttributeLoad NameLoad attr Str NameLoad Call AttributeLoad NameLoad attr Str NameLoad Call AttributeLoad NameLoad attr Str NameLoad Call AttributeLoad NameLoad attr Str body Continue Assign NameStore Call AttributeLoad NameLoad attr Str NameLoad If CompareIsNot NameLoad NameLoad body Assign TupleStore NameStore NameStore TupleLoad Call AttributeLoad NameLoad attr Num Call AttributeLoad NameLoad attr Num Assign NameStore Call AttributeLoad NameLoad attr Str Str NameLoad Assign NameStore Call AttributeLoad NameLoad attr Str Str NameLoad AugAssignAdd NameStore BinOpMod Str TupleLoad NameLoad SubscriptLoad NameLoad Index NameLoad Assign NameStore BinOpMod Str TupleLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore BinOpAdd NameLoad Str AugAssignAdd NameStore Call AttributeLoad Str attr NameLoad Return NameLoad decorator_list Assign NameStore Call AttributeLoad NameLoad attr Str If BoolOpOr CompareLt Call NameLoad AttributeLoad NameLoad attr Num UnaryOpNot Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num body Print Str orelse Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad AttributeLoad NameLoad attr Index Num Print Call NameLoad Call AttributeLoad NameLoad attr Num Call AttributeLoad NameLoad attr Num Call AttributeLoad NameLoad attr Num
N/A N/A 
Create the web2py code needed to access your mysql legacy db.

To make this work all the legacy tables you want to access need to have an "id" field.

This plugin needs:
mysql
mysqldump
installed and globally available.

Under Windows you will probably need to add the mysql executable directory to the PATH variable,
you will also need to modify mysql to mysql.exe and mysqldump to mysqldump.exe below.
Just guessing here :)

Access your tables with:
legacy_db(legacy_db.mytable.id>0).select()

If the script crashes this is might be due to that fact that the data_type_map dictionary below is incomplete.
Please complete it, improve it and continue.

Created by Falko Krause, minor modifications by Massimo Di Pierro and Ron McOuat
 N/A subprocess N/A re N/A sys N/A data_type_map N/A dict varchar string int integer integer integer tinyint integer smallint integer mediumint integer bigint integer float double double double char string decimal integer date date time time timestamp datetime datetime datetime binary blob blob blob tinyblob blob mediumblob blob longblob blob text text tinytext text mediumtext text longtext text mysql N/A N/A database_name username password N/A N/A N/A p N/A N/A subprocess Popen N/A mysql N/A --user=%s username N/A --password=%s password --execute=show tables; database_name stdin N/A subprocess PIPE stdout N/A subprocess PIPE stderr N/A subprocess PIPE N/A N/A sql_showtables stderr N/A N/A p communicate N/A tables N/A N/A N/A re sub \|\s+([^\|*])\s+.* x N/A x N/A N/A N/A sql_showtables split N/A 1 N/A connection_string N/A legacy_db = DAL('mysql://%s:%s@localhost/%s') N/A username password database_name N/A legacy_db_table_web2py_code N/A N/A table_name tables N/A N/A p N/A N/A subprocess Popen N/A mysqldump N/A --user=%s username N/A --password=%s password --skip-add-drop-table --no-data database_name table_name stdin N/A subprocess PIPE stdout N/A subprocess PIPE stderr N/A subprocess PIPE N/A N/A sql_create_stmnt stderr N/A N/A p communicate N/A N/A CREATE sql_create_stmnt N/A N/A sql_lines N/A N/A sql_create_stmnt split N/A sql_lines N/A filter N/A N/A N/A x N/A N/A N/A N/A x N/A N/A N/A x N/A 2 N/A -- /* sql_lines N/A web2py_table_code N/A table_name N/A N/A N/A N/A re search CREATE TABLE .(\S+). \( N/A sql_lines N/A 0 group 1 N/A fields N/A N/A line N/A sql_lines N/A 1 -1 N/A N/A N/A N/A N/A re search KEY line N/A N/A re search PRIMARY line N/A N/A re search  ID line N/A N/A line startswith ) N/A N/A N/A hit N/A N/A re search (\S+)\s+(\S+)(,| )( .*)? line N/A N/A hit None N/A N/A N/A name d_type N/A N/A N/A hit group 1 N/A N/A hit group 2 N/A d_type N/A N/A re sub (\w+)\(.* \1 d_type N/A name N/A N/A re sub ` name N/A web2py_table_code N/A 
    Field('%s','%s'), N/A name N/A data_type_map N/A d_type N/A web2py_table_code N/A legacy_db.define_table('%s',%s
    migrate=False) N/A table_name web2py_table_code N/A N/A N/A legacy_db_table_web2py_code append web2py_table_code N/A legacy_db_web2py_code N/A connection_string N/A legacy_db_web2py_code N/A N/A 

#--------
 join legacy_db_table_web2py_code N/A legacy_db_web2py_code N/A N/A regex N/A N/A re compile (.*?):(.*?)@(.*) N/A N/A N/A N/A len N/A sys argv 2 N/A N/A N/A regex match N/A N/A sys argv N/A 1 N/A N/A USAGE:

    extract_mysql_models.py username:password@data_basename

 N/A N/A m N/A N/A regex match N/A N/A sys argv N/A 1 N/A N/A mysql N/A N/A m group 3 N/A N/A m group 1 N/A N/A m group 2