Hi Christoph,

> > items = meta.metadata.tables.get(table).select().order_by(column)
>
> I'm no SQLAlchemy guru. But with SQLAlchemy 0.4.* that should just be:
>
>        items = sqlalchemy.select([yourtable])

This is a generic aproach to display/browse data in tables, which are
*not* defined in my model. Instead I reflect the tables of a existing
database and ask dynamically for the tablenames. This is the complete
code:

    def table(self, table=None):
        if not table:
            c.tables = meta.metadata.table_iterator()
            return render('/databrowse/tables.html')
        current_page = request.GET.get('current_page', 0)
        c.table=table
        column = request.GET.get('column')
        c.columns = meta.metadata.tables.get(table).c
        print "old ",
meta.Session.execute(meta.metadata.tables.get(table).select()).rowcount
        print "new ", meta.Session.execute(select([model.t_ml])).rowcount
        items = meta.metadata.tables.get(table).select().order_by(column)
        c.page = paginate.Page(items, sqlalchemy_session=meta.Session,
current_page=current_page)
        return render('/databrowse/table.html')

> What do you get if you run
>
>        meta.Session.execute(sqlalchemy.select([yourtable])).rowcount
>

        print "old ",
meta.Session.execute(meta.metadata.tables.get(mytable).select()).rowcount
        print "new ", meta.Session.execute(select([model.mytable])).rowcount

returns
old  -1
new  -1

If I find the time, I will try to reproduce this with a small setup.
By the way, I use mssql-engine with pyodbc. Perhhaps this is a bug in
sqlalchemy (ms-sql/pyodbc)?
Tobias

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to