当前位置:网站首页>PgSQL reports an error: current transaction is aborted, commands ignored until end of transaction block
PgSQL reports an error: current transaction is aborted, commands ignored until end of transaction block
2022-06-11 05:51:00 【Lao Liu selling vegetables at the corner of the street】
We are PG database , When auto commit of transactions is turned off , Will often encounter such problems
ERROR: current transaction is aborted, commands ignored until end of transaction block
Why did it cause such a problem , as a result of
Postgres In the database , In the same transaction, if there is an error in a database operation , Then the database after this transaction will make mistakes .
Let's take a very simple example
test=# select * from test1;
ERROR: relation "test1" does not exist
LINE 1: select * from test1;
Time: 0.376 msThis is the time , Because this operation is wrong , Then all operations in the following session will report
ERROR: current transaction is aborted, commands ignored until end of transaction block
This is the time , We have to solve this problem , Only use rollback, Or is it commit To solve the
That's the point ,PG Not humane enough
If it is python operation pgsql, The solution is as follows :
try:
function()
except Exception as e:
print('------------>',e)
cursor.execute("ROLLBACK") # If the data is wrong , Perform a rollback operation
cursor.execute("ROLLBACK")
First try Execute the code you need , then except Execute the above rollback operation to continue execution
边栏推荐
- DISM命令使用小结
- Informatica: six steps of data quality management
- NDK learning notes (VII) system configuration, users and groups
- What is a thread pool?
- NDK learning notes (IX) POSIX sockect connection oriented communication
- Share an RSA encryption and decryption tool class, including public key encryption, private key decryption, private key encryption, public key decryption, private key signature, public key verificatio
- Multi thread tutorial (XXIX) immutable design
- [daily exercises] 1 Sum of two numbers
- Combination sum Ⅳ -- leetcode exercise
- "All in one" is a platform to solve all needs, and the era of operation and maintenance monitoring 3.0 has come
猜你喜欢

NDK learning notes (13) create an avi video player using avilib+opengl es 2.0

Implementation of data access platform scheme (Youzu network)

NDK R21 compiles ffmpeg 4.2.2 (x86, x86_64, armv7, armv8)

NFC Development -- the method of using NFC mobile phones as access control cards (II)

Cocoatouch framework and building application interface

What happened to the young man who loved to write code -- approaching the "Yao Guang young man" of Huawei cloud

Deep learning distributed training

NDK learning notes (XI) POSIX sockect local communication

初步了解多任务学习

Wechat custom component - style - slot
随机推荐
微信小程序text内置组件换行符不换行的原因-wxs处理换行符,正则加段首空格
NDK R21 compiles ffmpeg 4.2.2+x264 and converts video files using ffmpeg
Recherche sur l'optimisation de Spark SQL basée sur CBO pour kangourou Cloud Stack
Do we really need conference headphones?
Elk log system practice (VI): comparison between vector and filebeat for technology selection
Further efficient identification of memory leakage based on memory optimization tool leakcanary and bytecode instrumentation technology
微信自定义组件---样式--插槽
Concepts and differences of parallel computing, distributed computing and cluster (to be updated for beginners)
The meaning in the status column displayed by PS aux command
Multithreading tutorial (XXVI) field updater and atomic accumulator
配置Rust编译环境
NFC Development -- the method of using NFC mobile phones as access control cards (II)
Pycharm usage experience
Flask develops and implements the like comment module of the online question and answer system
[go deep into kotlin] - get to know flow for the first time
Write a list with kotlin
Start the project using the locally configured gradle
BERT知识蒸馏
NDK learning notes (I)
Wechat custom component - style - slot