当前位置:网站首页>Postgres establish connection and delete records
Postgres establish connection and delete records
2022-07-05 21:07:00 【cuisidong1997】
establish Cursor object
cur = conn.cursor()
perform sql command : Create a new table test
cur.execute(“CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);”)
Pass data to formal parameters in the statement , Give Way Psycopg Deal with the correct conversion ( You can avoid sql Inject )
cur.execute(“INSERT INTO test (num, data) VALUES (%s, %s)”,
… (100, “abc’def”))
Interpolated data , And get the results
cur.execute(“SELECT * FROM test;”)
cur.fetchone()
(1, 100, “abc’def”)
Submit data changes
conn.commit()
close Cursor Object and connection object
cur.close()
conn.close()
边栏推荐
- 字典树简单入门题(居然是蓝题?)
- js常用方法封装
- Material design component - use bottomsheet to show extended content (II)
- Display DIN 4102-1 Class B1 fire test requirements
- Monorepo management methodology and dependency security
- ClickHouse 复制粘贴多行sql语句报错
- Clion configures Visual Studio (MSVC) and JOM multi-core compilation
- When a user logs in, there is often a real-time drop-down box. For example, entering an email will @qq com,@163. com,@sohu. com
- WPF gets the control in the datagridtemplatecolumn of the specified row and column in the DataGrid
- @Validated基础参数校验、分组参数验证和嵌套参数验证
猜你喜欢
Pytoch practice -- MNIST dataset handwritten digit recognition
研学旅游实践教育的开展助力文旅产业发展
第05章_存储引擎
leetcode:1755. Sum of subsequences closest to the target value
Influence of oscilloscope probe on signal source impedance
Golang(1)|从环境准备到快速上手
Which is the best online collaboration product? Microsoft loop, notion, flowus
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
随机推荐
Display DIN 4102-1 Class B1 fire test requirements
Enclosed please find. Net Maui's latest learning resources
树莓派4B上ncnn转换出来的模型调用时总是崩溃(Segment Fault)的原因
Clion configures Visual Studio (MSVC) and JOM multi-core compilation
leetcode:1755. Sum of subsequences closest to the target value
秋招将临 如何准备算法面试、回答算法面试题
判断横竖屏的最佳实现
Mode - "Richter replacement principle"
终端安全能力验证环境搭建和渗透测试记录
selenium 获取dom内属性值的方法
教你自己训练的pytorch模型转caffe(一)
校招期间 准备面试算法岗位 该怎么做?
显示屏DIN 4102-1 Class B1防火测试要求
LeetCode_ Hash table_ Difficulties_ 149. Maximum number of points on the line
When a user logs in, there is often a real-time drop-down box. For example, entering an email will @qq com,@163. com,@sohu. com
LeetCode_哈希表_困难_149. 直线上最多的点数
wpf 获取datagrid 中指定行列的DataGridTemplateColumn中的控件
100 cases of shell programming
Sophomore personal development summary
PVC 塑料片BS 476-6 火焰传播性能测定