Chlorus / sqlautocode

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

MySQLdb reflection error #29

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Upgrade sqlautocode to 0.6b1
2. run sql autocode on a mysql database. For example:
------------------------------------------------------------------------
$ sqlautocode mysql://user:pass@localhost/db_name
Starting...
Traceback (most recent call last):
  File "/mnt/md0/www/tg2/tg2env/bin/sqlautocode", line 9, in <module>
    load_entry_point('sqlautocode==0.6b1', 'console_scripts', 'sqlautocode')()
  File "/mnt/md0/www/tg2/tg2env/lib/python2.6/site-packages/sqlautocode-0.6b1-py2.6.egg/sqlautocode/main.py", line 41, in main
    reflection_schema = db.dialect.get_default_schema_name(conn)
AttributeError: 'MySQLDialect_mysqldb' object has no attribute 
'get_default_schema_name'
-------------------------------------------------------------------------

What is the expected output? What do you see instead?
Model definitions should have been generated, instead I get error.

What version of the product are you using? On what operating system?
sqlautocode 0.6b1, sqlalchemy 0.6.5, MySQLdb 1.2.3, Linux 2.6.35.7

This error wasn't there in the previous version as I used that version after 
patching it (for sqlalchemy 0.6) to generate SQLAlchemy models for the same 
database.

    Regards,

Kashif.

Original issue reported on code.google.com by a10n3.s7r1k3r@gmail.com on 3 Nov 2010 at 10:32

GoogleCodeExporter commented 9 years ago
I got this error too.

Original comment by ljsk...@gmail.com on 4 Nov 2010 at 4:39

GoogleCodeExporter commented 9 years ago
41 line
reflection_schema = db.dialect.get_default_schema_name(conn) => 
reflection_schema = db.dialect.default_schema_name

45 line
tablenames = db.dialect.table_names(conn, reflection_schema) =>
tablenames = db.dialect.get_table_names(conn, reflection_schema)

Original comment by alli...@naver.com on 12 Nov 2010 at 5:08

GoogleCodeExporter commented 9 years ago
The above patch worked for me. Would like to see the fixes in a released 
version!

Original comment by bob.ippo...@gmail.com on 23 Nov 2010 at 5:25

GoogleCodeExporter commented 9 years ago
FYI I had the same problem using PostgreSQL, this issue is not at all specific 
to a backend, it's just a general compatibility issue with sqlautocode and 
sqlalchemy.

Original comment by bob.ippo...@gmail.com on 23 Nov 2010 at 5:26

GoogleCodeExporter commented 9 years ago
Hey, thanks a lot for this code ! It worked like a charm, but i have modified 
it a bit so it works
with sqlalchemy 0.6.5, py27 and mysql-python1.2.3 (i didnt try it with other 
versions) ...

At main.py, line 42 (aprox) i changed:

    if options.schema != None:
        reflection_schema=options.schema
    else:
        try:
            #reflection_schema = db.dialect.get_default_schema_name(conn)
            reflection_schema = db.dialect.get_schema_names(conn)
        except NotImplementedError:
            reflection_schema = None

   #import ipdb; ipdb.set_trace()
    tablenames = db.dialect.get_table_names(conn, reflection_schema)

db.dialect.table_names and db.dialect.get_default_schema_name arent there 
anymore,
now they are:
- db.dialect.get_schema_names
- db.dialect.get_table_names.

With this i got the database in python code, AWSOME KAWAII !!! (nice in 
japanese x) but ...
at the top from models.py i got generated by sqlautocode, the import line that
says:

from sqlalchemy.databases.mysql import *

should be the next one:

from sqlalchemy.dialects.mysql.base import *

Thanks a lot for your work,
Cheers,

Original comment by edvm%x-i...@gtempaccount.com on 14 Dec 2010 at 4:35

GoogleCodeExporter commented 9 years ago
Added patch to handle the new sqlalchemy 0.6.5 method names (see 
http://www.sqlalchemy.org/docs/core/schema.html#sqlalchemy.engine.reflection.Ins
pector.default_schema_name)

Original comment by dav...@j5int.com on 5 Jan 2011 at 3:10

Attachments: