i didnt think this problem was in postgres (whats the error
message?) only in mysql.
solution:
f = table.select().alias('foo')
x = f.count(f.c.colname == value).scalar()
On Jul 25, 2006, at 5:06 AM, Khaled Daham wrote:
> Hi!
>
> I made something really funny today, I managed to have a
> Table.select().count(column == value) instead of a straight
> Table.count(column == value) and this resulted in the following.
>
> SQLError: (OperationalError) (1248, 'Every derived table must have
> its own alias') 'SELECT count(id) AS tbl_row_count \nFROM
> (SELECT dhcp_hosts.id AS id, dhcp_hosts.IP AS IP, dhcp_hosts.subnet
> AS subnet, dhcp_hosts.netmask AS netmask, dhcp_hosts.gw A
> S gw, dhcp_hosts.status AS status, dhcp_hosts.port AS port,
> dhcp_hosts.slot AS slot, dhcp_hosts.type AS type, dhcp_hosts.host
> AS host \nFROM dhcp_hosts \nWHERE dhcp_hosts.IP = %s)' ['127.0.0.1']
>
> The query fix is "simple", just add ' AS dhcp_host' after the
> subselect
> and mysql will be happy, the problem is that I dont see a straight
> forward
> way of doing it, been reading through ansisql.py, any hints ?
>
> This error manifests itself in both mysql 5.x and postgrsql 8.x, 4.0
> doesnt have subselects so this query wouldnt work in the first
> place, I
> think however that 4.1 is forgiving.
>
> /Khaled Daham
> Cell: +46-70-1810278
> FreeBSD: The Power to Serve! http://www.FreeBSD.org/
> This isn't rocket science -- but it _is_ computer science.
>
> ----------------------------------------------------------------------
> ---
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to
> share your
> opinions on IT & business topics through brief surveys -- and earn
> cash
> http://www.techsay.com/default.php?
> page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> Sqlalchemy-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Sqlalchemy-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlalchemy-users