Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get TypeError: __init__() got an unexpected keyword argument 'strict' when #9

Closed
agronholm opened this issue Jan 17, 2014 · 7 comments

Comments

@agronholm
Copy link
Owner

Originally reported by: Peter Harding (Bitbucket: peterlharding, GitHub: peterlharding)


I have experienced the following error with several of the databases I have attempted to use the utility with:

sqlacodegen "mysql+mysqldb://mw:C0mm@nd3r@localhost/trading"

Traceback (most recent call last):
File "/usr/local/bin/sqlacodegen", line 9, in
load_entry_point('sqlacodegen==1.1.4', 'console_scripts', 'sqlacodegen')()
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen/main.py", line 40, in main
generator = CodeGenerator(metadata, args.noindexes, args.noconstraints, args.nojoined, args.noinflect)
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen/codegen.py", line 520, in init
model = ModelClass(table, links[table.name], inflect_engine, not nojoined)
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen/codegen.py", line 263, in init
super(ModelClass, self).init(table)
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen/codegen.py", line 205, in init
column.type = column.type.adapt(cls)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/dialects/mysql/base.py", line 1175, in adapt
return sqltypes.Enum.adapt(self, impltype, **kw)
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/sqltypes.py", line 1145, in adapt
**kw
File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/sql/sqltypes.py", line 1110, in init
SchemaType.init(self, **kw)
TypeError: init() got an unexpected keyword argument 'strict'

I am running on a Debian 7 system using Python 2.7.5 and have the following packages installed:

pip list

albatross (1.42)
argparse (1.2.1)
Babel (1.3)
Beaker (1.6.3)
blinker (1.3)
bzr (2.6.0dev3)
bzr-etckeeper (0.0.0)
chardet (2.0.1)
configobj (4.7.2)
decorator (3.4.0)
distribute (0.6.49)
ez-setup (0.9)
Flask (0.10.1)
Flask-Babel (0.9)
Flask-Login (0.2.6)
Flask-Mail (0.9.0)
Flask-OpenID (1.1.1)
Flask-SQLAlchemy (0.16)
Flask-WhooshAlchemy (0.54a)
Flask-WTF (0.9.4)
flup (1.0.2)
fpconst (0.7.2)
fpdf (1.7)
httplib2 (0.7.4)
inflect (0.2.4)
ipython (0.13.2)
itsdangerous (0.23)
Jinja2 (2.7.2)
keyring (1.6)
launchpadlib (1.9.12)
lazr.restfulclient (0.13.3)
lazr.uri (1.0.3)
MarkupSafe (0.18)
mercurial (2.6.3)
migrate (0.2.2)
moin (1.9.7)
MySQL-python (1.2.3)
numpy (1.7.1)
oauth (1.0.1)
paramiko (1.10.1)
parsedatetime (0.8.7)
passlib (1.6.1)
pbr (0.5.23)
pexpect (2.4)
PIL (1.1.7)
pip (1.5)
ply (3.4)
pycrypto (2.6)
pygame (1.9.1release)
Pygments (1.6)
pygobject (3.8.2)
pygpgme (0.2)
PyICU (1.5)
pyinotify (0.9.3)
pyOpenSSL (0.13)
PySimpleSOAP (1.10)
pysqlite (2.6.3)
python-apt (0.8.9)
python-dateutil (1.5)
python-debian (0.1.21-nmu2)
python-debianbts (1.11)
python-distutils-extra (2.38)
python-openid (2.2.5)
pytz (2013.8)
recaptcha-client (1.0.6)
reportbug (6.4.4)
reportlab (2.5)
scipy (0.12.0)
SecretStorage (1.0.0)


@agronholm
Copy link
Owner Author

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun):


Here's a more readably formatted traceback starting with reproduction instructions:

mysql> create database sqlacodegentest;
Query OK, 1 row affected (0.00 sec)

mysql> use sqlacodegentest;
Database changed
mysql> CREATE TABLE `accounttypes` (
    ->   `is_hidden` enum('false','true') NOT NULL DEFAULT 'false'
    -> ) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.03 sec)

mysql> Bye
(HybridCluster)exarkun@top:~/Projects/HybridCluster/develop$ sqlacodegen mysql+pymysql://root@localhost/sqlacodegentest
Traceback (most recent call last):
  File "/home/exarkun/Environments/HybridCluster/bin/sqlacodegen", line 9, in <module>
    load_entry_point('sqlacodegen==1.1.4.post1', 'console_scripts', 'sqlacodegen')()
  File "/home/exarkun/Projects/sqlacodegen/trunk/sqlacodegen/main.py", line 40, in main
    generator = CodeGenerator(metadata, args.noindexes, args.noconstraints, args.nojoined, args.noinflect)
  File "/home/exarkun/Projects/sqlacodegen/trunk/sqlacodegen/codegen.py", line 524, in __init__
    model = ModelTable(table)
  File "/home/exarkun/Projects/sqlacodegen/trunk/sqlacodegen/codegen.py", line 209, in __init__
    column.type = column.type.adapt(cls)
  File "/home/exarkun/Environments/HybridCluster/lib/python2.7/site-packages/sqlalchemy/dialects/mysql/base.py", line 1175, in adapt
    return sqltypes.Enum.adapt(self, impltype, **kw)
  File "/home/exarkun/Environments/HybridCluster/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py", line 1145, in adapt
    **kw
  File "/home/exarkun/Environments/HybridCluster/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py", line 1110, in __init__
    SchemaType.__init__(self, **kw)
TypeError: __init__() got an unexpected keyword argument 'strict'

@agronholm
Copy link
Owner Author

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun):


Considering the exception comes out of SQLAlchemy and the strict keyword is being added by SQLAlchemy, I wonder if this is actually a SQLAlchemy bug, not a sqlacodegen bug. However, I don't know the SQLAlchemy APIs well enough to say for sure one way or the other.

@agronholm
Copy link
Owner Author

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun):


Confirmed this is still an issue with latest development version (0.9.2dev, git rev ee1f4d21037690ad996c5eacf7e1200e92f2fbaa)

@agronholm
Copy link
Owner Author

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun):


Okay, some more digging suggests this really is a SQLAlchemy bug, probably introduced by git rev 2692238f.

@agronholm
Copy link
Owner Author

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun):


http://www.sqlalchemy.org/trac/ticket/2917

@agronholm
Copy link
Owner Author

Original comment by Jean-Paul Calderone (Bitbucket: exarkun, GitHub: exarkun):


SQLAlchemy ticket is fixed now. I suggest this issue is now resolved, at least when using the very latest SQLAlchemy.

@agronholm
Copy link
Owner Author

Original comment by Alex Grönholm (Bitbucket: agronholm, GitHub: agronholm):


Alright then, case closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant