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
  Table data with BeatifulSoup gerry84 11 392 Oct-23-2019, 10:09 AM
Last Post: Larz60+
  Want to scrape a table data and export it into CSV format tahir1990 9 333 Oct-22-2019, 08:03 AM
Last Post: buran
  Beautifulsoup table question tantony 5 180 Sep-30-2019, 03:26 PM
Last Post: tantony
  Using flask to add data to sqlite3 table with PRIMARY KEY catafest 1 1,528 Sep-09-2019, 07:00 AM
Last Post: buran
  BeautifulSoup: Error while extracting a value from an HTML table kawasso 3 276 Aug-25-2019, 01:13 AM
Last Post: kawasso
  Scrap text out of td table from URLS Gochix2020 4 455 Aug-03-2019, 02:56 AM
Last Post: Larz60+
  convert html table to json bhojendra 5 1,316 Jul-30-2019, 07:53 PM
Last Post: DeaD_EyE
  How to capture Single Column from Web Html Table? ahmedwaqas92 5 444 Jul-29-2019, 02:17 AM
Last Post: ahmedwaqas92
  table from wikipedia flow50 5 657 Jul-01-2019, 07:12 PM
Last Post: snippsat
  get link and link text from table metulburr 5 443 Jun-13-2019, 07:50 PM
Last Post: snippsat

Forum Jump:

Users browsing this thread: 1 Guest(s)