wow I am impressed with the work you put into that little script that was just a byproduct for moving my legacy mysqldb to web2py :) thank you
On Sep 9, 7:01 am, ron_m <[email protected]> wrote: > On Sep 8, 1:30 pm, mdipierro <[email protected]> wrote: > > > > So maybe tonight do you want me to go through the manual and find all > > > the missing datatypes and try to add them to the map? > > > I would not stop you. ;-) > > Here is a replacement data_type_map, it was shuffled a bit to put like > types together for easier maintenance. I didn't know what to do with > the YEAR type so it is commented out. I am not sure the decimal type > should be mapped to integer since the DAL accepts decimal(n,M) as a > field type. > > data_type_map = 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', > #year = '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', > ) > > I also fixed the remaining problem in the line match re.search so line > 75 or line 87 after above dict is changed > > 75c87 > < hit = re.search('(\S+)\s+(\S+)( .*)?', line) > --- > > > hit = re.search('(\S+)\s+(\S+)(,| )( .*)?', line) > > this fixes the matching on lines like > > `description` longtext, > > The comma immediately after the type got included as part of the type > string match in error. > > Here is the output for the auth_event table > > legacy_db.define_table('auth_event', > Field('id','integer'), > Field('time_stamp','datetime'), > Field('client_ip','string'), > Field('user_id','integer'), > Field('origin','string'), > Field('description','text'), > migrate=False) > > The id field should not be printed since it will be added > automatically. > > The varchar fields have a length in () e.g. varchar(64) which could be > used to add on a length=N value for the Field constructor. The same > holds true for int fields but I don't think there is a real use for > that. > > There is no recognition of foreign keys, fixing this would probably be > a significant effort. Some human intervention required as it > stands. ;-) > > It certainly is a great start to getting a model file for an existing > MySQL database. > > Ron

