Hi, i have i am developing an app in django where i used sqlalchemy to connect to the mssql server and query the database. There is a case where i have to access data from two tables. i have manage to extract the data, but the data duplicated itself once loaded on the template. not sure what i am doing wrong
appreciate any assistances view.py engine=create_engine('mssql+pymssql://user:pass@server /db') connection=engine.connect() metadata=MetaData() pay=Table('EmpCalculateDetail',metadata,autoload=True,autoload_with=engine) allo=Table('AllowanceDeduction',metadata,autoload=True,autoload_with=engine) stmt=select([pay.columns.calc_emp_code,pay.columns.calc_ad_code,pay.columns.calc_value,allo.columns.AllowanceDeductionDescription]) stmt=stmt.where(pay.columns.calc_emp_code=='RB') results=connection.execute(stmt).fetchall() return render(request,'payslip.html',locals()) template.html <table class="table table-striped"> <thead> <tr> <th>Employee</th> <th>Allowance/Deduction Code</th> <th>Description</th> <th>Amount</th> <th>rate</th> <th>Post Date</th> </tr> </thead> <tr> {%for a in results%} <td>{{a.calc_emp_code}}</td> <td>{{a.calc_ad_code}}</td> <td>{{a.AllowanceDeductionDescription}}</td> <td>{{a.calc_value}}</td> {%endfor%} </table> cheers, -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.