On Sep 7, 5:10 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > If you have a mysql database running locally, please help me test it. >
First problem I ran into Last line parameters are out of order on mysql() call so it outputs incorrect database URL string $ python scripts/extract_mysql_models.py user:p...@db_name user pass db_name legacy_db = DAL('mysql://pass:db_n...@localhost/user') Changed last line print mysql(m.group(1),m.group(2),m.group(3)) to be print mysql(m.group(3),m.group(1),m.group(2)) Next run I get a key error on the data_type_map $ python scripts/extract_mysql_models.py user:p...@db_name user pass db_name Traceback (most recent call last): File "scripts/extract_mysql_models.py", line 100, in <module> print mysql(m.group(3),m.group(1),m.group(2)) File "scripts/extract_mysql_models.py", line 82, in mysql web2py_table_code += "\n Field('%s','%s'),"% (name,data_type_map[d_type]) KeyError: 'datetime' Thinking I could fix this I added a line to the data_type_map last 2 lines so you get a reference point are timestamp = 'datetime', datetime = 'datetime', ) Next run produces $ python scripts/extract_mysql_models.py user:p...@db_name user pass db_name Traceback (most recent call last): File "scripts/extract_mysql_models.py", line 101, in <module> print mysql(m.group(3),m.group(1),m.group(2)) File "scripts/extract_mysql_models.py", line 80, in mysql name, d_type = hit.group(1), hit.group(2) AttributeError: 'NoneType' object has no attribute 'group' Added a print line statement just above line 80 and it stops on the mysqldump of the auth_event table at line `description` longtext, So it looks like hit is empty because there is no match on this line (print line and flush commented out hit = re.search('(\S+) (\S+) .*', line) # print line # if hit != None: # print hit.group(1), hit.group(2) # sys.stdout.flush() name, d_type = hit.group(1), hit.group(2) Added a test for hit != None and see what hit.group(1) and hit.group(2) are they are the name and type except for this line. Looks like longtext needs to be added to the type dictionary but not getting there because of this failure. Added a test for hit == None with continue to skip around this code Next failure is in the CODE() call, global name CODE is not defined. Looks like a missing import - I am just running from the bash shell. I don't really understand why the regular expression filling hit fails but then I am weak in that area with Python. Here is the complete mysqldump CREATE TABLE stanza for auth_event I am using mysql 5.1.41 on Ubuntu 10.04 with all patches. CREATE TABLE `auth_event` ( `id` int(11) NOT NULL AUTO_INCREMENT, `time_stamp` datetime DEFAULT NULL, `client_ip` varchar(512) DEFAULT NULL, `user_id` int(11) DEFAULT NULL, `origin` varchar(512) DEFAULT NULL, `description` longtext, PRIMARY KEY (`id`), KEY `user_id__idx` (`user_id`), CONSTRAINT `auth_event_ibfk_1` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8; Time to catch some ZZZs it is 1 am Ron