Skip to content
This repository was archived by the owner on Aug 19, 2024. It is now read-only.
This repository was archived by the owner on Aug 19, 2024. It is now read-only.

flask with data from reflected tables. #9

@okyere

Description

@okyere

@orf Thanks for creating this library. I've been trying to use datatables with my flask application but most examples I see with serverside processing have been php.
I see that your example uses the pyramid framework - which I know nothing about. I'm a newbie and I've used flask for about 3 months now.

  1. The rows I'm trying to display are not from a mapped sqlachemy class. I'm using sqlalchemy to reflect an existing table on the schema; and then attempting to display it using datatables. So in the views.py where you pass the User class as an argument to DataTable, I can't do that. Can I still use your library with reflected tables without mapped classes?

  2. The way flask's view functions look is different from how pyramid's look. This is my view function that I'm hoping will provide data to the datatables plugin.

    @theapp.route('/upload/preview/', methods=['GET', 'POST'])
    def preview(tablename):
    m = db.MetaData()
    t = db.Table(tablename, m, autoload = True, autoload_with = db.engine)
    results = db.session.query(t).all()
    results = {"data":results}
    resp = make_response(json.dumps(results, cls=DateTimeEncoder, use_decimal=True))
    resp.headers['Content-type'] = "text/plain; charset=utf-8"
    return resp

    A table's name is passed to the view function; I use sqlalchemy to reflect that table to get all the rows of the table; and then I'm attempting provide a response object that contains the data. This is not working & that's why I'm attempting to use your library. Since I don't use requests explicitly in flask, how do I get the request.GET parameter to pass to DataTables?

  3. You have table.add_data and table.searchable in the views function. I think you're trying to add the data to be displayed and make the data searchable respectively. How do I do those in flask? Do I have to write my own search and sort functions?

In brief, I have a simple case of pulling data from a reflected table. I want to be able to display that data in a datatable with serverside processing. Being able to search, sort, and show about 20 rows per page will be ideal. Please help me connect the dots. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions