当前位置:网站首页>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()
边栏推荐
猜你喜欢
产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现
示波器探头对信号源阻抗的影响
【案例】元素的显示与隐藏的运用--元素遮罩
Enclosed please find. Net Maui's latest learning resources
10000+ 代码库、3000+ 研发人员大型保险集团的研发效能提升实践
PVC 塑料片BS 476-6 火焰传播性能测定
ArcGIS栅格重采样方法介绍
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
【案例】定位的运用-淘宝轮播图
随机推荐
Is it necessary for bazel to learn
【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
ODPs next map / reduce preparation
MYSQL IFNULL使用功能
What are the requirements of UL 2043 test for drive housing in the United States?
vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
PHP deserialization +md5 collision
Viewrootimpl and windowmanagerservice notes
bazel是否有学习的必要
【案例】元素的显示与隐藏的运用--元素遮罩
EN 438-7 laminated sheet products for building covering decoration - CE certification
AITM2-0002 12s或60s垂直燃烧试验
研學旅遊實踐教育的開展助力文旅產業發展
基于flask写一个接口
Promouvoir le développement de l'industrie culturelle et touristique par la recherche, l'apprentissage et l'enseignement pratique du tourisme
校招期间 准备面试算法岗位 该怎么做?
Deep merge object deep copy of vant source code parsing
leetcode:1139. 最大的以 1 为边界的正方形
Pytorch实战——MNIST数据集手写数字识别
面试官:并发编程实战会吗?(线程控制操作详解)