Python operation PostgreSQL

xiaoxiao2021-03-06  45

2005-2-23 This sticker is really a short time than the last post, continue to work hard! Today, try Python's database operability: connect PostgreSQL with Python (personal favorite). First install postgreSQL, http://www.postgresql.org then check it up, and there is a Python connection program PygreSQL he is divided into two modules, old PG, and new PGDBPG documents: http: / / www.pgsqldb.org/pgsqldoc-7.2c/pygreSQL.htmlpgdb document: http://www.python.org/peps/pep-0249.html Try PG today, the code is really simple:

Import pgdb = pg.connect (dbname = 'yanxu', host = 'localhost', user = 'qingfeng', passwd = '123') for obj in db.query ("Select * from table1" .dict (): Print (): print Obj ['user_name'] db.close ()

转载请注明原文地址:https://www.9cbs.com/read-54718.html

New Post(0)