当前位置: 首页 > news >正文

网站建设空格怎么打wordpress 文章找不到

网站建设空格怎么打,wordpress 文章找不到,郑州市二七区建设局网站,网站开发有哪些框架其实在Python中可以用来连接PostgreSQL的模块很多#xff0c;这里比较推荐psycopg2。psycopg2安装起来非常的简单(pip install psycopg2)#xff0c;这里主要重点介绍下如何使用。安装psycopg2模块#xff1a;怎么验证是否已经安装过psycopy2?编写上面代码#xff0c;运行…其实在Python中可以用来连接PostgreSQL的模块很多这里比较推荐psycopg2。psycopg2安装起来非常的简单(pip install psycopg2)这里主要重点介绍下如何使用。安装psycopg2模块怎么验证是否已经安装过psycopy2?编写上面代码运行看是否抛出缺少psycopg2模块。安装方法11)使用psycopg2-2.4.2.win-amd64-py2.7-pg9.0.4-release.exe安装下载地址:http://vdisk.weibo.com/s/Cd8pPaw56Ozys直接运行exe不出错误运行上边代码验证代码无错误基本算是安装完成了。2)怎么卸载2.1)找到安装目录C:\Python27发现下边包含文件:Removepsycopg2.exe,运行来删除2.2)如果运行失败的话进入目录C:\Python27\Lib\site-packages下找到psycopg2文件夹和psycopg2-2.4.2-py2.7.egg-info文件右键删除。2.3)运行上边的代码确认是否删除成功。安装方法2下载文件psycopg2-2.6.2-cp27-none-win_amd64.whl我这里把psycopg2-2.6.2-cp27-none-win_amd64.whl拷贝到安装目录下Scripts文件夹中。cmd中运行代码pip install C:\Python27\Scripts\psycopg2-2.6.2-cp27-none-win_amd64.whl运行上边的代码确认是否删除成功。通过psycopg2操作数据库使用账户postgres创建测试数据库testdb。参考yiibai.comAPI:S.N. API 描述1 psycopg2.connect(databasetestdb,userpostgres,passwordcohondob,host127.0.0.1,port5432)这个API打开一个连接到PostgreSQL数据库。如果成功打开数据库时它返回一个连接对象。2 connection.cursor()该程序创建一个光标将用于整个数据库使用Python编程。3 cursor.execute(sql [,optional parameters])此例程执行SQL语句。可被参数化的SQL语句(即占位符而不是SQL文字)。 psycopg2的模块支持占位符用s标志例如cursor.execute(insert into people values (%s,%s),(who,age))4 curosr.executemany(sql,seq_of_parameters)该程序执行SQL命令对所有参数序列或序列中的sql映射。5 curosr.callproc(procname[,parameters])这个程序执行的存储数据库程序给定的名称。该程序预计为每一个参数参数的顺序必须包含一个条目。6 cursor.rowcount这个只读属性它返回数据库中的行的总数已修改插入或删除最后 execute*().7 connection.commit()此方法提交当前事务。如果不调用这个方法无论做了什么修改自从上次调用commit()是不可见的从其他的数据库连接。8 connection.rollback()此方法会回滚任何更改数据库自上次调用commit()方法。9 connection.close()此方法关闭数据库连接。请注意这并不自动调用commit()。如果你只是关闭数据库连接而不调用commit()方法首先那么所有更改将会丢失10 cursor.fetchone()这种方法提取的查询结果集的下一行返回一个序列或者无当没有更多的数据是可用的。11 cursor.fetchmany([sizecursor.arraysize])这个例程中取出下一个组的查询结果的行数返回一个列表。当没有找到记录返回空列表。该方法试图获取尽可能多的行所显示的大小参数。12 cursor.fetchall()这个例程获取所有查询结果(剩余)行返回一个列表。空行时则返回空列表。打开数据库连接import osimport sysimport psycopg2def connectPostgreSQL():conn psycopg2.connect(databasetestdb,passwordnew.1234,port5432)print connect successful!if __name____main__:connectPostgreSQL()创建表操作import osimport sysimport psycopg2def connectPostgreSQL():conn psycopg2.connect(databasetestdb,port5432)print connect successful!cursorconn.cursor()cursor.execute(create table public.member(id integer not null primary key,name varchar(32) not null,password varchar(32) not null,singal varchar(128)))conn.commit()conn.close()print table public.member is created!if __name____main__:connectPostgreSQL()Insert 操作import osimport sysimport psycopg2def connectPostgreSQL():conn psycopg2.connect(databasetestdb,port5432)print connect successful!cursorconn.cursor()cursor.execute(create table public.member(id integer not null primary key,singal varchar(128)))conn.commit()conn.close()print table public.member is created!def insertOperate():conn psycopg2.connect(databasetestdb,port5432)cursorconn.cursor()cursor.execute(insert into public.member(id,name,password,singal)\values(1,member0,password0,signal0))cursor.execute(insert into public.member(id,singal)\values(2,member1,password1,signal1))cursor.execute(insert into public.member(id,singal)\values(3,member2,password2,signal2))cursor.execute(insert into public.member(id,singal)\values(4,member3,password3,signal3))conn.commit()conn.close()print insert records into public.memmber successfullyif __name____main__:#connectPostgreSQL()insertOperate()Select 操作import osimport sysimport psycopg2def connectPostgreSQL():conn psycopg2.connect(databasetestdb,singal varchar(128)))conn.commit()conn.close()print table public.member is created!def insertOperate():conn psycopg2.connect(databasetestdb,signal3))conn.commit()conn.close()print insert records into public.memmber successfullydef selectOperate():conn psycopg2.connect(databasetestdb,port5432)cursorconn.cursor()cursor.execute(select id,singal from public.member where id2)rowscursor.fetchall()for row in rows:print id,row[0],,name,row[1],pwd,row[2],singal,row[3],\nconn.close()if __name____main__:#connectPostgreSQL()#insertOperate()selectOperate()结果Python 2.7.12 (v2.7.12:d33e0cf91556,Jun 27 2016,15:24:40) [MSC v.1500 64 bit (AMD64)] on win32Type copyright,credits or license() for more information. RESTART: C:\Users\Administrator\Desktop\mutilpleTest.py id 3,name member2,pwd password2,singal signal2id 4,name member3,pwd password3,singal signal3update操作import osimport sysimport psycopg2def connectPostgreSQL():conn psycopg2.connect(databasetestdb,\nconn.close()def updateOperate():conn psycopg2.connect(databasetestdb,port5432)cursorconn.cursor()cursor.execute(update public.member set nameupdate ... where id2)conn.commit()print Total number of rows updated :,cursor.rowcountcursor.execute(select id,singal from public.member)rowscursor.fetchall()for row in rows:print id,\nconn.close()if __name____main__:#connectPostgreSQL()#insertOperate()#selectOperate()updateOperate()结果Python 2.7.12 (v2.7.12:d33e0cf91556,credits or license() for more information. RESTART: C:\Users\Administrator\Desktop\mutilpleTest.py Total number of rows updated : 1id 1,name member0,pwd password0,singal signal0id 3,singal signal3id 2,name update ...,pwd password1,singal signal1Delete操作import osimport sysimport psycopg2def connectPostgreSQL():conn psycopg2.connect(databasetestdb,\nconn.close()def deleteOperate():conn psycopg2.connect(databasetestdb,port5432)cursorconn.cursor()cursor.execute(select id,\nprint begin deletecursor.execute(delete from public.member where id2)conn.commit()print end deleteprint Total number of rows deleted :,cursor.rowcountcursor.execute(select id,\nconn.close()if __name____main__:#connectPostgreSQL()#insertOperate()#selectOperate()#updateOperate()deleteOperate()结果Python 2.7.12 (v2.7.12:d33e0cf91556,credits or license() for more information. RESTART: C:\Users\Administrator\Desktop\mutilpleTest.py id 1,singal signal1begin deleteend deleteTotal number of rows deleted : 1id 1,singal signal3
http://www.sadfv.cn/news/164697/

相关文章:

  • 柳州网站建设 来宾市网站制作免费播放电视剧的app有哪些
  • 自费社保太坑了亏大了seo网站标题
  • 张家港网站建设做网站遵义建立公司网站的步骤
  • 网站建设 图纸网大理装饰公司做网站
  • 商业活动的网站建设成都装修网站制作价格
  • 网站建设工作方案范文苏州网站建设公司排名
  • 网站开发能不能用win7系统用备忘录制作一个网站的制作
  • 企业做网站大概需要多少钱自动化培训机构排名
  • 网站设计需要需要用wordpress主题中的psd
  • 做网站电脑和手机都是一样可以看吗erp是什么办公软件
  • 招聘网站怎么做吸引人北京网站建设价格低
  • html5网站带后台域名后有个wordpress
  • 打开一个网站为繁体字是怎么做的网站建设中图片电话
  • 网站源码下载插件图片在线高清处理
  • 用cms做个网站珠海做小程序的公司
  • 九一人才网招聘网官方网站公司接软件开发平台
  • 公司做网站推广有没有用西安网站建设l西安搜推宝网络
  • 企业网站建设湖南岚鸿商务网站建设实验报告
  • 10个网站用户体验优化的研究结果软考高项彻底没用了
  • 天津网站建设首选 津坤科技html5国内网站欣赏
  • 网站建设案例新闻个人网站建设知乎
  • app在线开发网站建设重庆建设工程造价网官网
  • 有网站用nodejs做后台安卓优化大师下载
  • 网站建设中联系我们怎么写做网站续费
  • 微网站设计制作青海旭云网站建设
  • 好的做网站博客seo优化技术
  • 河北省电力建设第一工程公司网站上海人才网赶集网
  • 衣服网站建设方案开个网站做代理赚钱吗
  • 网站的ico图标做多大网站模版下载
  • 建设网站租用空间搭建 网站 实例