上学期学习数据库的时候就是学的PostGreSQL,这次也不想再学新的了。
照例贴出学习时的连接:
下载psycopg2:http://www.initd.org/psycopg/download/
参考:http://www.cnblogs.com/leajon-first/archive/2012/11/23/2784339.html
http://deepfuture.iteye.com/blog/1184244
import psycopg2
conn = psycopg2.connect("dbname=crawler user=Administrator")
cur = conn.cursor()
cur.execute("CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);")
#cur.execute("INSERT INTO test(num,data) VALUES(%s,%s)"%(102,"abc"))
cur.execute("INSERT INTO test(num,data) VALUES(102,"abc")")
cur.execute("SELECT * FROM test;")
row = cur.fetchone()
print row
conn.commit()
cur.close()
conn.close()
print "over"
经过这三次的学习,不知道还有多久可以做出个有用的东西!