Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 sqlalchemy DataTables::"No data available in table" when using self-joined table

I need to run a query with sqlalchemy on self-joined table, I tried to use alias as suggested by many forums but no data displayed.
Please find below my code:

class Employee(db.Model):

__tablename__ = 'employee' #self referenced table

id = db.Column(db.Integer, primary_key=True)
name = db.Column(db.String(200), nullable=False)
surname = db.Column(db.String(200), nullable=False)
email = db.Column(db.String(200), nullable=False)
id_emp_sup = db.Column(db.Integer, db.ForeignKey(""))
#emp_sup = db.relationship('Employee',backref = 'employee')
#emp_sup = db.relationship('Employee', foreign_keys="[id_emp_sup]")
id_structure = db.Column(db.Integer, db.ForeignKey(""))
id_function = db.Column(db.Integer, db.ForeignKey(""))

def __init__(self, name, surname, email, id_emp_sup, id_structure): = name
self.surname = surname = email
self.id_emp_sup = id_emp_sup
self.id_structure = id_structure
self.id_function = id_function

Emp = db.aliased(Employee)

columns = [
ColumnDT( +' '+ Employee.surname),
ColumnDT( +' '+ Emp.surname)
result = db.session.query().select_from(Employee).join(Emp)
params = request.args.to_dict()
rowTable = DataTables(params, result, columns)
return jsonify(rowTable.output_result())

I want to display the full name of each employee with his manager (identified by id_emp_sup) by using sqlalchemy datatable.
Larz60+ wrote Nov-22-2018, 10:28 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  scraping multiple pages from table bandar 1 112 Jun-27-2020, 10:43 PM
Last Post: Larz60+
  Flask export/upload database table in cvs/xlsx format steve87bg 4 153 Jun-19-2020, 01:46 PM
Last Post: steve87bg
  Scraping a dynamic data-table in python through AJAX request filozofo 0 224 Mar-18-2020, 01:44 PM
Last Post: filozofo
  Servicenow Table API bdpy9 2 256 Mar-10-2020, 08:29 PM
Last Post: bdpy9
  Imprt HTML table to array meleghengersor 2 235 Jan-23-2020, 10:23 AM
Last Post: perfringo
  How get table element zinho 5 558 Dec-28-2019, 09:25 PM
Last Post: snippsat
  Table data with BeatifulSoup gerry84 11 929 Oct-23-2019, 10:09 AM
Last Post: Larz60+
  Want to scrape a table data and export it into CSV format tahir1990 9 763 Oct-22-2019, 08:03 AM
Last Post: buran
  Beautifulsoup table question tantony 5 417 Sep-30-2019, 03:26 PM
Last Post: tantony
  Using flask to add data to sqlite3 table with PRIMARY KEY catafest 1 1,974 Sep-09-2019, 07:00 AM
Last Post: buran

Forum Jump:

Users browsing this thread: 1 Guest(s)