Comments (8)
@ablekh correct that should work. Check that it's version 1.1.6 in __init__.py
. I don't think you need to rename but I'm not entirely sure re the issue you're facing.
from flask-sqlacodegen.
@ablekh glad to hear it works! Big thanks to @con-av for the PR. Unfortunately I don't know much about FAB.
from flask-sqlacodegen.
Given this was the top google result when searching for my own similiar traceback here's what I've found after some digging. The problem seems to result from sqlalchemy changing the type of constraint.columns
from a simple list to a ColumnCollection
in version 1.0[1]. If all you need is the column name the change to make is simply replacing constraint.columns
with constraint.column_keys
.
from flask-sqlacodegen.
Thanks @Janzert. I'm going to mark this as closed.
from flask-sqlacodegen.
Hello, @Janzert and @ksindi. I experienced the same error as the OP. I followed @Janzert's recommendation above and replaced all instances of constraint.columns
with constraint.column_keys
in codegen.py
(there seem to be no other files affected). Then I tried to reinstall the package via python setup.py install
. However, the change results in KeyError = 0
error going away, but another error appearing, as follows:
Traceback (most recent call last):
File "/usr/local/bin/sqlacodegen", line 9, in <module>
load_entry_point('sqlacodegen==1.1.5.pre2', 'console_scripts', 'sqlacodegen')()
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen-1.1.5.pre2-py2.7.egg/sqlacodegen/main.py", line 57, in main
args.flask, fkcols)
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen-1.1.5.pre2-py2.7.egg/sqlacodegen/codegen.py", line 597, in __init__
model = ModelClass(table, links[table.name], inflect_engine, not nojoined)
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen-1.1.5.pre2-py2.7.egg/sqlacodegen/codegen.py", line 313, in __init__
for constraint in sorted(table.constraints, key=_get_constraint_sort_key):
File "/usr/local/lib/python2.7/dist-packages/sqlacodegen-1.1.5.pre2-py2.7.egg/sqlacodegen/codegen.py", line 74, in _get_constraint_sort_key
return constraint.__class__.__name__[0] + repr(constraint.column_keys)
AttributeError: 'PrimaryKeyConstraint' object has no attribute 'column_keys'
Am I missing something? I would appreciate any help in fixing this issue.
from flask-sqlacodegen.
@ablekh Just merged @con-av PR which might fix the issue.
from flask-sqlacodegen.
@ksindi Thank you. How to correctly apply your recent merge: just reinstall the software (git pull origin master
, followed by python setup.py install
)? If so, do I still need to rename constraint.columns
into constraint.column_keys
?
from flask-sqlacodegen.
@ksindi Just tested. I stashed my prior changes (var renaming), updated my local repository, rebuilt and reinstalled the software. Happy to report that it works fine without the prior changes (so I'll just discard them). I was able to successfully auto-generate models - thank you for all your work and help! Now I just hope that the generated models will work well with other modules in my small Flask-AppBuilder (FAB) application, but that's another story... (BTW, do you have any experience with FAB, by any chance?)
from flask-sqlacodegen.
Related Issues (20)
- Missing s in table name HOT 1
- --noclasses is ignored. HOT 2
- Execution crashes (unsupported operand type(s) for +: 'NoneType' and 'unicode') HOT 2
- TypeError: unsupported operand type(s) for +: 'NoneType' and 'str' HOT 5
- Option to db.Float(11, False) or db.Float(11, True) HOT 1
- Wrong import generated view class
- Error generating model for mssql+pymssql database on which sqlacodegen worked HOT 5
- console command writing models as type bytes HOT 1
- Add support for SET column type [wishlist] HOT 2
- Can I use this library such as `pytest.main()`? HOT 1
- SQLite3 does not generate classes,(python 3.8.1 sqlite 3.2.5) HOT 2
- Don't generate Classe for postgresql HOT 1
- --nocomments not work
- Update releases HOT 1
- The data table name is inconsistent with the generated class name HOT 1
- Wrong code generated for timestamp, tinyint and boolean datatypes HOT 1
- AttributeError: module 'sqlalchemy' has no attribute '__all__'. Did you mean: '__file__'? HOT 3
- Rename --ignorefk as name and function do not match HOT 1
- Only model generation HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flask-sqlacodegen.