1

I have a class

class vw_invoice_header(db.Model): __tablename__ = "vw_invoice_header" tax_amount = db.column(db.Numeric) total_price = db.column(db.Numeric) invc_number = db.Column(db.String(40)) term_code = db.Column(db.String(20)) order_date = db.Column(db.Date) airway_bill = db.Column(db.String(40)) inh_auto_key = db.Column(db.Integer,primary_key=True) 

Now I get a result from an oracle db as below

invc = vw_invoice_header.query.filter_by(inh_auto_key=20643519).first() 

I'm trying to use the value below to get a nicely formatted price in my jinja2 template

"{:8,.2f}".format(invc.total_price) 

This throws an error, AttributeError: type object 'Numeric' has no attribute 'lower' I have no idea how to just print out this numeric :/ Im a newb to python been using it for a week.

Thanks Cameron

1
  • Are the db.column's in your code not supposed to be db.Column? Commented Jul 22, 2016 at 12:52

1 Answer 1

2

Your first two fields should be db.Column not db.column (note the capitalization). db.column creates a sqlalchemy.sql.elements.ColumnClause object whereas db.Column creates a sqlalchemy.sql.schema.Column object like you want.

class vw_invoice_header(db.Model): __tablename__ = "vw_invoice_header" tax_amount = db.Column(db.Numeric) total_price = db.Column(db.Numeric) invc_number = db.Column(db.String(40)) term_code = db.Column(db.String(20)) order_date = db.Column(db.Date) airway_bill = db.Column(db.String(40)) inh_auto_key = db.Column(db.Integer,primary_key=True) 

Once you correct this, the Numeric datatype will behave just as you expect.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! - Always ends up being something simple

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.