[MonetDB-users] selecting with keywords as column names
Hi, I'm trying to write SQLALchemy wrapper for MonetDB. For the introspection part, I need a query something like this: SELECT c.name AS attname, c.type AS format_type, c.default, c.null as attnotnull, c.number as attnum, c.id AS oid FROM columns C WHERE c.table_id=9782; Obviously, the problem with the above is, there are keywords like default, null, type etc., How do I make the above query work? The intended output (taken from PG): ---expected output (taken from postgrsql) attname | format_type | default | attnotnull | attnum | table_oid --------------+-----------------------+-------------------------------------+------------+--------+----------- student_id | integer | nextval('student_id_seq'::regclass) | t | 1 | 16399 student_name | character varying(80) | | t | 2 | 16399 school_id | integer | | t | 3 | 16399 Regards, Pradeep -- Home: http://btbytes.com Heart: http://sampada.net
On 18-08-2007 01:29:35 +0530, Pradeep Gowda wrote:
Hi, I'm trying to write SQLALchemy wrapper for MonetDB.
For the introspection part, I need a query something like this: SELECT c.name AS attname, c.type AS format_type, c.default, c.null as attnotnull, c.number as attnum, c.id AS oid FROM columns C WHERE c.table_id=9782;
Obviously, the problem with the above is, there are keywords like default, null, type etc.,
How do I make the above query work?
You can just quote them using the SQL standard quote character. E.g.: SELECT "c"."name" AS "attname", ...
participants (2)
-
Fabian Groffen
-
Pradeep Gowda