Re: How to send multiple SQL commands from Python?

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: How to send multiple SQL commands from Python?
Дата
Msg-id 200910101827.08786.aklaver@comcast.net
обсуждение исходный текст
Ответ на Re: How to send multiple SQL commands from Python?  ("Massa, Harald Armin" <chef@ghum.de>)
Список pgsql-general
On Saturday 10 October 2009 5:48:39 pm Massa, Harald Armin wrote:
> Adrian,
>
> While I was walking the dog I thought of a better solution.
>
> > sql_str = """ALTER TABLE  %(xn)s OWNER TO xdev;
> > GRANT ALL ON TABLE  %(xn)s TO xdev;
> > REVOKE ALL ON TABLE %(xn)s FROM PUBLIC;
> > GRANT SELECT ON TABLE %(xn)s TO PUBLIC;"""
> >
> > cur.execute(sql_str,{'xn':table_name})
> > --
>
> This will not work.
>
> Because: "xn" will be escaped as "data", that is... the resulting string
> will be:
>
> ALTER TABLE E'waschbaer' ONER TO xdev;
>
> which obviously is not what you want.

Thanks for pointing that out.

--
Adrian Klaver
aklaver@comcast.net

В списке pgsql-general по дате отправления:

Предыдущее
От: "Massa, Harald Armin"
Дата:
Сообщение: Re: How to send multiple SQL commands from Python?
Следующее
От: justin
Дата:
Сообщение: Re: interface for "non-SQL people"