psycopg2.NotSupportedError: INSERT with ON CONFLICT clause cannot be used with table that has INSERT or UPDATE rulesSolutions for INSERT OR UPDATE on SQL ServerInsert, on duplicate update in PostgreSQL?Manual inserts on a postgres table with a primary key sequenceInsert into a MySQL table or update if existsPostgresql, update if row with some unique value exists, else insertcreating insert, update rules in postgresql tablesHow to UPSERT (MERGE, INSERT … ON DUPLICATE UPDATE) in PostgreSQL?How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?PostgreSQL 9.5 Insert/Update while partitioning tablemake django not insert certain fields

Blood-based alcohol for vampires?

How can solar sailed ships be protected from space debris?

What is the difference between case and adpositions?

what is the meaning of "stock" dilution on the Massive Dev Chart Website?

What instances can be solved today by modern solvers (pure LP)?

Will greasing clutch parts make it softer

"Best practices" for formulating MIPs

Can the word "coexist" be used for more than two things/people/subjects/... etc?

Use real text instead of lipsum in moderncv quote alignment

Birthday girl's casino game

Do I pay more tax when 2 extra payments are in this paypacket

Are the plates of a battery really charged?

Why is the saxophone not common in classical repertoire?

C++20 with u8, char8_t and std::string?

Should I hide my travel history to the UK when I apply for an Australian visa?

What could a Medieval society do with excess animal blood?

What is -(-2,3,4)?

Wrong Output in self defined Quaternionic Multiplication

How come having a Deathly Hallow is not a big deal?

When should we use dependency injection (C#)

How can I get a file's size with C++17?

Do I need to be legally qualified to install a Hive smart thermostat?

Can I deep fry food in butter instead of vegetable oil?

Has there ever been a cold war other than between the U.S. and the U.S.S.R.?



psycopg2.NotSupportedError: INSERT with ON CONFLICT clause cannot be used with table that has INSERT or UPDATE rules


Solutions for INSERT OR UPDATE on SQL ServerInsert, on duplicate update in PostgreSQL?Manual inserts on a postgres table with a primary key sequenceInsert into a MySQL table or update if existsPostgresql, update if row with some unique value exists, else insertcreating insert, update rules in postgresql tablesHow to UPSERT (MERGE, INSERT … ON DUPLICATE UPDATE) in PostgreSQL?How can the INSERT … ON CONFLICT (id) DO UPDATE… syntax be used with a sequence ID?PostgreSQL 9.5 Insert/Update while partitioning tablemake django not insert certain fields






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















When i'm creating a update RULE beside of CONFLICT clause then that error is throwing.



Here my conflict code



 insert_query = "INSERT INTO my_company (id, name, login, logout) VALUES %s
ON CONFLICT (id) DO NOTHING"


my update RULE



CREATE RULE log_shoelace AS ON UPDATE TO my_company
WHERE NEW.login <> OLD.login or NEW.logout <> OLD.logout
DO INSERT INTO my_company VALUES (
new.id, new.name, new.login, new.logout, new.interval_time, current_date);


my_company table field contains id, name, login. logout, interval_time, today.



if any data is updated then insert those data into same table.
But here i can't use CONFLICT and RULE in the same time. So in this case what can i do?



Thanks.



Table creation and sequence creation for testing:



CREATE SEQUENCE IF NOT EXISTS my_company_id_seq;

CREATE TABLE public.my_company
( id integer NOT NULL DEFAULT nextval('my_company_id_seq'::regclass)
, name character varying(50)
, login time without time zone
, logout time without time zone
, interval_time time without time zone
, today date DEFAULT CURRENT_DATE
, CONSTRAINT my_company_pkey PRIMARY KEY (id)
);









share|improve this question



















  • 1





    Do you want to insert on conflict or update on conflict? It seems like you're trying to do an INSERT ... ON CONFLICT DO UPDATE. It looks like you don't need a rule at all to me. What are the data types for login and logout? If they're timestamp, it's unlikely they'd ever be equal.

    – J Spratt
    Mar 25 at 18:22












  • login and logout both are TIME data type

    – Prosenjit
    Mar 25 at 18:23











  • my conflict is for insert and rule is for update

    – Prosenjit
    Mar 25 at 18:24











  • but without creating a RULE how can i insert data into today fields when something will be updated?

    – Prosenjit
    Mar 25 at 18:26






  • 1





    Take a look at this SQLFiddle and let me know if you still think you need a RULE: sqlfiddle.com/#!17/073e9/16. Unless I'm missing something, you get the same results using INSERT ... ON CONFLICT UPDATE. Except there are times where your RULE will fail on a duplicate key violation.

    – J Spratt
    Mar 25 at 20:51


















0















When i'm creating a update RULE beside of CONFLICT clause then that error is throwing.



Here my conflict code



 insert_query = "INSERT INTO my_company (id, name, login, logout) VALUES %s
ON CONFLICT (id) DO NOTHING"


my update RULE



CREATE RULE log_shoelace AS ON UPDATE TO my_company
WHERE NEW.login <> OLD.login or NEW.logout <> OLD.logout
DO INSERT INTO my_company VALUES (
new.id, new.name, new.login, new.logout, new.interval_time, current_date);


my_company table field contains id, name, login. logout, interval_time, today.



if any data is updated then insert those data into same table.
But here i can't use CONFLICT and RULE in the same time. So in this case what can i do?



Thanks.



Table creation and sequence creation for testing:



CREATE SEQUENCE IF NOT EXISTS my_company_id_seq;

CREATE TABLE public.my_company
( id integer NOT NULL DEFAULT nextval('my_company_id_seq'::regclass)
, name character varying(50)
, login time without time zone
, logout time without time zone
, interval_time time without time zone
, today date DEFAULT CURRENT_DATE
, CONSTRAINT my_company_pkey PRIMARY KEY (id)
);









share|improve this question



















  • 1





    Do you want to insert on conflict or update on conflict? It seems like you're trying to do an INSERT ... ON CONFLICT DO UPDATE. It looks like you don't need a rule at all to me. What are the data types for login and logout? If they're timestamp, it's unlikely they'd ever be equal.

    – J Spratt
    Mar 25 at 18:22












  • login and logout both are TIME data type

    – Prosenjit
    Mar 25 at 18:23











  • my conflict is for insert and rule is for update

    – Prosenjit
    Mar 25 at 18:24











  • but without creating a RULE how can i insert data into today fields when something will be updated?

    – Prosenjit
    Mar 25 at 18:26






  • 1





    Take a look at this SQLFiddle and let me know if you still think you need a RULE: sqlfiddle.com/#!17/073e9/16. Unless I'm missing something, you get the same results using INSERT ... ON CONFLICT UPDATE. Except there are times where your RULE will fail on a duplicate key violation.

    – J Spratt
    Mar 25 at 20:51














0












0








0


1






When i'm creating a update RULE beside of CONFLICT clause then that error is throwing.



Here my conflict code



 insert_query = "INSERT INTO my_company (id, name, login, logout) VALUES %s
ON CONFLICT (id) DO NOTHING"


my update RULE



CREATE RULE log_shoelace AS ON UPDATE TO my_company
WHERE NEW.login <> OLD.login or NEW.logout <> OLD.logout
DO INSERT INTO my_company VALUES (
new.id, new.name, new.login, new.logout, new.interval_time, current_date);


my_company table field contains id, name, login. logout, interval_time, today.



if any data is updated then insert those data into same table.
But here i can't use CONFLICT and RULE in the same time. So in this case what can i do?



Thanks.



Table creation and sequence creation for testing:



CREATE SEQUENCE IF NOT EXISTS my_company_id_seq;

CREATE TABLE public.my_company
( id integer NOT NULL DEFAULT nextval('my_company_id_seq'::regclass)
, name character varying(50)
, login time without time zone
, logout time without time zone
, interval_time time without time zone
, today date DEFAULT CURRENT_DATE
, CONSTRAINT my_company_pkey PRIMARY KEY (id)
);









share|improve this question
















When i'm creating a update RULE beside of CONFLICT clause then that error is throwing.



Here my conflict code



 insert_query = "INSERT INTO my_company (id, name, login, logout) VALUES %s
ON CONFLICT (id) DO NOTHING"


my update RULE



CREATE RULE log_shoelace AS ON UPDATE TO my_company
WHERE NEW.login <> OLD.login or NEW.logout <> OLD.logout
DO INSERT INTO my_company VALUES (
new.id, new.name, new.login, new.logout, new.interval_time, current_date);


my_company table field contains id, name, login. logout, interval_time, today.



if any data is updated then insert those data into same table.
But here i can't use CONFLICT and RULE in the same time. So in this case what can i do?



Thanks.



Table creation and sequence creation for testing:



CREATE SEQUENCE IF NOT EXISTS my_company_id_seq;

CREATE TABLE public.my_company
( id integer NOT NULL DEFAULT nextval('my_company_id_seq'::regclass)
, name character varying(50)
, login time without time zone
, logout time without time zone
, interval_time time without time zone
, today date DEFAULT CURRENT_DATE
, CONSTRAINT my_company_pkey PRIMARY KEY (id)
);






database postgresql rules insert-update






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 25 at 20:51









J Spratt

5144 silver badges12 bronze badges




5144 silver badges12 bronze badges










asked Mar 25 at 17:55









ProsenjitProsenjit

512 silver badges10 bronze badges




512 silver badges10 bronze badges







  • 1





    Do you want to insert on conflict or update on conflict? It seems like you're trying to do an INSERT ... ON CONFLICT DO UPDATE. It looks like you don't need a rule at all to me. What are the data types for login and logout? If they're timestamp, it's unlikely they'd ever be equal.

    – J Spratt
    Mar 25 at 18:22












  • login and logout both are TIME data type

    – Prosenjit
    Mar 25 at 18:23











  • my conflict is for insert and rule is for update

    – Prosenjit
    Mar 25 at 18:24











  • but without creating a RULE how can i insert data into today fields when something will be updated?

    – Prosenjit
    Mar 25 at 18:26






  • 1





    Take a look at this SQLFiddle and let me know if you still think you need a RULE: sqlfiddle.com/#!17/073e9/16. Unless I'm missing something, you get the same results using INSERT ... ON CONFLICT UPDATE. Except there are times where your RULE will fail on a duplicate key violation.

    – J Spratt
    Mar 25 at 20:51













  • 1





    Do you want to insert on conflict or update on conflict? It seems like you're trying to do an INSERT ... ON CONFLICT DO UPDATE. It looks like you don't need a rule at all to me. What are the data types for login and logout? If they're timestamp, it's unlikely they'd ever be equal.

    – J Spratt
    Mar 25 at 18:22












  • login and logout both are TIME data type

    – Prosenjit
    Mar 25 at 18:23











  • my conflict is for insert and rule is for update

    – Prosenjit
    Mar 25 at 18:24











  • but without creating a RULE how can i insert data into today fields when something will be updated?

    – Prosenjit
    Mar 25 at 18:26






  • 1





    Take a look at this SQLFiddle and let me know if you still think you need a RULE: sqlfiddle.com/#!17/073e9/16. Unless I'm missing something, you get the same results using INSERT ... ON CONFLICT UPDATE. Except there are times where your RULE will fail on a duplicate key violation.

    – J Spratt
    Mar 25 at 20:51








1




1





Do you want to insert on conflict or update on conflict? It seems like you're trying to do an INSERT ... ON CONFLICT DO UPDATE. It looks like you don't need a rule at all to me. What are the data types for login and logout? If they're timestamp, it's unlikely they'd ever be equal.

– J Spratt
Mar 25 at 18:22






Do you want to insert on conflict or update on conflict? It seems like you're trying to do an INSERT ... ON CONFLICT DO UPDATE. It looks like you don't need a rule at all to me. What are the data types for login and logout? If they're timestamp, it's unlikely they'd ever be equal.

– J Spratt
Mar 25 at 18:22














login and logout both are TIME data type

– Prosenjit
Mar 25 at 18:23





login and logout both are TIME data type

– Prosenjit
Mar 25 at 18:23













my conflict is for insert and rule is for update

– Prosenjit
Mar 25 at 18:24





my conflict is for insert and rule is for update

– Prosenjit
Mar 25 at 18:24













but without creating a RULE how can i insert data into today fields when something will be updated?

– Prosenjit
Mar 25 at 18:26





but without creating a RULE how can i insert data into today fields when something will be updated?

– Prosenjit
Mar 25 at 18:26




1




1





Take a look at this SQLFiddle and let me know if you still think you need a RULE: sqlfiddle.com/#!17/073e9/16. Unless I'm missing something, you get the same results using INSERT ... ON CONFLICT UPDATE. Except there are times where your RULE will fail on a duplicate key violation.

– J Spratt
Mar 25 at 20:51






Take a look at this SQLFiddle and let me know if you still think you need a RULE: sqlfiddle.com/#!17/073e9/16. Unless I'm missing something, you get the same results using INSERT ... ON CONFLICT UPDATE. Except there are times where your RULE will fail on a duplicate key violation.

– J Spratt
Mar 25 at 20:51













0






active

oldest

votes










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343860%2fpsycopg2-notsupportederror-insert-with-on-conflict-clause-cannot-be-used-with-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes




Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.







Is this question similar to what you get asked at work? Learn more about asking and sharing private information with your coworkers using Stack Overflow for Teams.



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55343860%2fpsycopg2-notsupportederror-insert-with-on-conflict-clause-cannot-be-used-with-t%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해