当前位置:网站首页>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()
边栏推荐
- Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
- 学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
- vant 源码解析之 utils/index.ts 工具函数
- [case] Application of positioning - Taobao rotation map
- 终端安全能力验证环境搭建和渗透测试记录
- js常用方法封装
- Influence of oscilloscope probe on measurement bandwidth
- 获取前一天的js(时间戳转换)
- 2. < tag hash table, string> supplement: Sword finger offer 50 The first character DBC that appears only once
- wpf 获取datagrid 中指定行列的DataGridTemplateColumn中的控件
猜你喜欢
木板ISO 5660-1 热量释放速率摸底测试
基于flask写一个接口
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
教你自己训练的pytorch模型转caffe(一)
PVC 塑料片BS 476-6 火焰传播性能测定
XML modeling
Golang(1)|从环境准备到快速上手
Explain various hot issues of Technology (SLB, redis, mysql, Kafka, Clickhouse) in detail from the architecture
The development of research tourism practical education helps the development of cultural tourism industry
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
随机推荐
EN 438-7 laminated sheet products for building covering decoration - CE certification
ODPS 下一个map / reduce 准备
【日常训练】729. 我的日程安排表 I
LeetCode: Distinct Subsequences [115]
[case] Application of positioning - Taobao rotation map
教你自己训练的pytorch模型转caffe(三)
Vant source code parsing event Detailed explanation of TS event processing global function addeventlistener
Comparison table of foreign lead American abbreviations
启牛2980有没有用?开户安全吗、
Get JS of the previous day (timestamp conversion)
获取前一天的js(时间戳转换)
MySQL 千万数据量深分页优化, 拒绝线上故障!
Pytorch实战——MNIST数据集手写数字识别
AITM2-0002 12s或60s垂直燃烧试验
Material design component - use bottomsheet to show extended content (II)
Longest swing sequence [greedy practice]
字典树简单入门题(居然是蓝题?)
【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
systemd-resolved 开启 debug 日志
postgres 建立连接并删除记录