Re: Insert data if it is not existing
От | Adrian Klaver |
---|---|
Тема | Re: Insert data if it is not existing |
Дата | |
Msg-id | f45d20d9-76c4-5985-9b53-d1549dd60657@aklaver.com обсуждение исходный текст |
Ответ на | Re: Insert data if it is not existing (tango ward <tangoward15@gmail.com>) |
Список | pgsql-general |
On 05/23/2018 07:59 PM, tango ward wrote: > > > > On Thu, May 24, 2018 at 10:51 AM, Adrian Klaver > Try the example I showed previously. If you do not want to use the > the named parameters e.g %(name)s then use use %s and a tuple like: > > ''' > INSERT INTO my_table(%s, %s) > WHERE NOT EXISTS(SELECT name FROM my_table WHERE name= %s) > ''', (Scott', 23, 'Scott')) > > > > > > Trying to coordinate with Lead Dev about adding Index On The Fly > > > > > > -- > Adrian Klaver > adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com> > > > Thank you Master, the name=%s solved it. Please show the complete example that worked for completeness. FYI, psql is your friend. When I work out queries I try them in psql first and then move up to whatever interface I will be using. This is usually done on a dev server so mistakes don't bring things down. If I have to work on a production instance then I do: BEGIN; some_query; ROLLBACK; -- Adrian Klaver adrian.klaver@aklaver.com
В списке pgsql-general по дате отправления: