ksindi / flask-sqlacodegen

:sake: Automatic model code generator for SQLAlchemy with Flask support
Other
336 stars 60 forks source link

console command writing models as type bytes #30

Closed ghostzero192 closed 6 years ago

ghostzero192 commented 6 years ago

I am using the master release of the library, when i execute the flask-sqlacodegen it creates the outfile without errors but the models are writen like this:

b"class Ueb(Base):\n tablename = 'ueb'\n\n idueb = Column(Integer, primary_key=True, server_default=FetchedValue())\n nombre = Column(String(50), nullable=False)"

instead of the classes i am using python 3.6.2 and SQLAlchemy-1.1.11

ghostzero192 commented 6 years ago

Solved, i compared the codegen.py with the one in the previous version and used the way it writes the models in the outfile: for model in self.models:

print('\n\n', file=outfile)

    #print(model.render().rstrip('\n').encode('utf-8'), file=outfile)
    print('\n\n' + model.render().rstrip('\n'), file=outfile)

replaced the commented lines with the last one