How to quote table and schema without Table object?

34 views
Skip to first unread message

Stefan Urbanek

unread,
Oct 22, 2012, 12:58:00 AM10/22/12
to sqlal...@googlegroups.com
Hi,

I am creating some custom compiled constructions and I need to create properly quoted schema and table, however I have both only as strings because the table does not exist yet (for example: CREATE TABLE ... AS SELECT ...). It looks like all table quote_* methods in IdentifierPreparer expect table object. Is there a way how can I get schema.table quoting just from strings?

Regards,

Stefan

Michael Bayer

unread,
Oct 22, 2012, 10:50:23 AM10/22/12
to sqlal...@googlegroups.com
there's the quote() method which doesn't expect any schema object, just the name and a flag "force" which you can leave as None to have it determine quoting automatically.

--
You received this message because you are subscribed to the Google Groups "sqlalchemy" group.
To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/5SJoREJHKTkJ.
To post to this group, send email to sqlal...@googlegroups.com.
To unsubscribe from this group, send email to sqlalchemy+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en.

Stefan Urbanek

unread,
Oct 22, 2012, 12:20:10 PM10/22/12
to sqlal...@googlegroups.com
Thanks. So it would be safe to do it as:

table_ref = "%s.%s" % (preparer.quote(schema_name, None), preparer.quote(table_name, None))

to make: "a schema"."a table"?

Can I assume that this syntax same for all dialects?

Stefan

Michael Bayer

unread,
Oct 22, 2012, 1:18:02 PM10/22/12
to sqlal...@googlegroups.com
yeah quote() is always there and should do whatever the dialect thinks it should.


To view this discussion on the web visit https://groups.google.com/d/msg/sqlalchemy/-/u7HrZKAlgIUJ.
Reply all
Reply to author
Forward
0 new messages