当前位置:网站首页>postgres 建立连接并删除记录
postgres 建立连接并删除记录
2022-07-05 21:04:00 【cuisidong1997】
建立Cursor对象
cur = conn.cursor()
执行sql命令:创建一个新表test
cur.execute(“CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);”)
传递数据到语句中形参中,让Psycopg处理正确的转换问题(可以避免sql注入)
cur.execute(“INSERT INTO test (num, data) VALUES (%s, %s)”,
… (100, “abc’def”))
插叙数据,并获取结果
cur.execute(“SELECT * FROM test;”)
cur.fetchone()
(1, 100, “abc’def”)
提交数据改变
conn.commit()
关闭Cursor对象和连接对象
cur.close()
conn.close()
边栏推荐
- Clear app data and get Icon
- Monorepo管理方法论和依赖安全
- Influence of oscilloscope probe on signal source impedance
- Monorepo management methodology and dependency security
- 使用WebAssembly在浏览器端操作Excel
- vant 源码解析 之深层 合并对象 深拷贝
- Is Kai Niu 2980 useful? Is it safe to open an account
- The reason why the ncnn converted model on raspberry pie 4B always crashes when called
- 教你自己训练的pytorch模型转caffe(三)
- Écrire une interface basée sur flask
猜你喜欢
ArcGIS\QGIS无插件加载(无偏移)MapBox高清影像图
Research and development efficiency improvement practice of large insurance groups with 10000 + code base and 3000 + R & D personnel
显示器要申请BS 476-7 怎么送样?跟显示屏一样吗??
【案例】定位的运用-淘宝轮播图
leetcode:1139. The largest square bounded by 1
2. < tag hash table, string> supplement: Sword finger offer 50 The first character DBC that appears only once
Écrire une interface basée sur flask
leetcode:1755. 最接近目标值的子序列和
MySQL InnoDB架构原理
实现浏览页面时校验用户是否已经完成登录的功能
随机推荐
Traps in the explode function in PHP
《SAS编程和数据挖掘商业案例》学习笔记# 19
当用户登录,经常会有实时的下拉框,例如,输入邮箱,将会@qq.com,@163.com,@sohu.com
Is Kai Niu 2980 useful? Is it safe to open an account
模式-“里氏替换原则”
[case] Application of element display and hiding -- element mask
基于flask写一个接口
Test of incombustibility of cement adhesives BS 476-4
EN 438-7 laminated sheet products for building covering decoration - CE certification
Duchefa low melting point agarose PPC Chinese and English instructions
教你自己训练的pytorch模型转caffe(三)
LeetCode_哈希表_困难_149. 直线上最多的点数
SYSTEMd resolved enable debug log
How to make ERP inventory accounts of chemical enterprises more accurate
Vant source code parsing event Detailed explanation of TS event processing global function addeventlistener
JS common method encapsulation
What are the requirements of UL 2043 test for drive housing in the United States?
Introduction to TS, constructor and its this, inheritance, abstract class and interface
Clear app data and get Icon
启牛2980有没有用?开户安全吗、