Chlorus / sqlautocode

Automatically exported from code.google.com/p/sqlautocode
Other
0 stars 0 forks source link

errors in sqlautocode 0.5 using sqlite, sqlalchemy 0.4.1 and python 2.5 #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Download and extract sqlautocode-0.5.tar.gz
1. Create a sample table, mine I used turbogears tg_user table
sqlite3 devdata.sqlite

CREATE TABLE tg_user (
        user_id INTEGER NOT NULL, 
        user_name VARCHAR(16), 
        email_address VARCHAR(255), 
        display_name VARCHAR(255), 
        password VARCHAR(40), 
        created TIMESTAMP, 
        PRIMARY KEY (user_id), 
         UNIQUE (user_name), 
         UNIQUE (email_address)
);

2. run python autocode.py -o model.py -u sqlite:///devdata.sqlite

You will get 

Traceback (most recent call last):
  File "autocode.py", line 69, in <module>
    filehandle = open(output, 'wU')
ValueError: universal newline mode can only be used with modes starting
with 'r'

This can be fixed by removing the 'U'

Then another error crops up at formatter.py in line 25

    if self._primary_key: kwarg.append( 'primary_key')
AttributeError: 'Column' object has no attribute '_primary_key'

This can be fixed by removing the '_'

After that it works for me.

I have attached the output of diff of the original and modified file/s.

Original issue reported on code.google.com by dak...@gmail.com on 1 Jan 2008 at 6:04

Attachments:

GoogleCodeExporter commented 9 years ago
I've hit the same problem. Using python 2.5, mysql 5.0. Please do a 0.5.1 
release :)

Original comment by aadi...@gmail.com on 7 Jan 2008 at 1:04

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
With Python 2.4.3 (and PostgreSQL 8.1.10), I did not receive the first error: 

(ValueError: universal newline mode can only be used with modes starting with 
'r')

using the original 0.5, but did encounter the second:

(AttributeError: 'Column' object has no attribute '_primary_key')

Original comment by dc.loco on 8 Jan 2008 at 7:39

GoogleCodeExporter commented 9 years ago
Fixed in 0.5.1

Original comment by spamsch@gmail.com on 10 Jan 2008 at 12:53