Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
563 views
in Technique[技术] by (71.8m points)

python - Django bulk_create with ignore_conflicts=True giving ProgrammingError

I am getting this strange error

ProgrammingError at /save_hsn/
syntax error at or near "ON"
LINE 1: ...021-01-28T06:17:43.784614+00:00'::timestamptz, 1) ON CONFLIC...

this is my views.py part where I am getting the error

user_gst_codes.objects.bulk_create(hsn_list, ignore_conflicts=True)

If I remove ignore_conflicts=True, everything works.

Moreover, I start getting this error after deploying my Django app on cPanel, on localhost this doesn't give any error.

On localhost-

Python 3.6.6, Django 3.1

On cPanel-

Python 3.6.11, Django 3.1

Is this an issue with the Python version?

I am inserting data in bulk and also need to keep the unique check. Any help would be appreciated.

question from:https://stackoverflow.com/questions/65932142/django-bulk-create-with-ignore-conflicts-true-giving-programmingerror

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Notice that the ON CONFLICT clause is only available from PostgreSQL 9.5. If you are using an earlier version, you will need a workaround to have the upsert feature. Please check local postgresql version and server postgresql version.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...