Python sqlite3ºÍµ¥Ôª²âÊÔ
import os
import unittest # °üº¬µ¥Ôª²âÊÔÄ£¿é
import sqlite3 as sqlite # °üº¬sqlite3Ä£¿é
def get_db_path():
return "sqlite_testdb"
class TransactionTests(unittest.TestCase): # µ¥Ôª²âÊÔµÚÒ»²½:¡¡ÓÉTestCaseÅÉÉúÀà
def setUp(self): # µ¥Ôª²âÊÔ»·¾³ÅäÖÃ
try:
os.remove(get_db_path())
except:
pass
self.con1 = sqlite.connect(get_db_path(), timeout=0.1) # Á¬½ÓÊý¾Ý¿â
self.cur1 = self.con1.cursor() # »ñÈ¡Óαê
self.con2 = sqlite.connect(get_db_path(), timeout=0.1)
self.cur2 = self.con2.cursor()
def tearDown(self): # µ¥Ôª²âÊÔ»·¾³Çå³ý
self.cur1.close() # ¹Ø±ÕÓαê
self.con1.close() # ¹Ø±ÕÁ¬½Ó
self.cur2.close()
self.con2.close()
os.unlink(get_db_path())
def CheckDMLdoesAutoCommitBefore(self):
self.cur1.execute("create table test(i)") # Ö´ÐÐSQL²éѯ
self.cur1.execute("insert into test(i) values (5)")
self.cur1.execute("create table test2(j)")
self.cur2.execute("select i from test")
res = self.cur2.fetchall()
self.failUnlessEqual(len(res), 1) # ²âÊÔ
def CheckInsertStartsTransaction(self):
self.cur1.execute("create table test(i)")
self.cur1.execute("insert into test(i) values (5)")
self.cur2.execute("select i from test")
res = self.cur2.fetchall()
self.failUnlessEqual(len(res), 0)
def CheckUpdateStartsTransaction(self):
self.cur1.execute("create table test(i)")
self.cur1.execute("insert into test(i) values (5)")
self.con1.commit()
self.cur1.execute("update test set i=6")
self.cur2.execute("select i from test")
res = self.cur2.fetchone()[0]
self.failUnlessEqual(res, 5)
def CheckDeleteStartsTransaction(self):
self.cur1.exec
Ïà¹ØÎĵµ£º
ת×Ô:http://blog.chinaunix.net/u3/103146/showart_2058891.html
PythonÕâÖֽű¾ÓïÑÔµÄÇ¿´ó¹¦ÄÜÔ½À´Ô½±»¹ã´óµÄ³ÌÐòÔ±ËùÖØÊÓ£¬ÕâÖÖ֮ǰÔÚ¹úÄÚÁ÷ÐжȲ»¸ßµÄÓïÑÔ½üÀ´ÆøÊƸßÕÇ¡£¸÷ÖÖµÚÈý·½Ä£¿é²ã³ö²»Çî¡£
±¾ÎĽéÉܵıãÊÇÒ»ÖÖÄܷdz£·½±ã²Ù×÷IEµÄµÚÈý·½¹¤¾ß£¬PAMIE£¬ËûÄÜÈÃÄãÈçͬдJSÒ»ÑùÀ´²Ù×÷IEä¯ÀÀÆ÷¡£°üÀ¨×Ô ......
http://code.google.com/p/android-scripting/
Android¿ªÊ¼Ö§³Ö½Å±¾ÓïÑÔPython¡¢Lua¼°Beanshell£¬Î´À´»¹½«Ö§³ÖRuby
×÷Õß Werner Schuster ÒëÕß ÕÅÁú ·¢²¼ÓÚ 2009Äê7ÔÂ5ÈÕ
Android Scripting Environment£¨ASE£©ÏîĿΪAndroidÔö¼ÓÁ˽ű¾Ö§³Ö¡£Í¨¹ý°²×°ASE£¬ÎÒÃÇ¿ÉÒÔÔÚÉ豸Éϱàд½Å±¾²¢Ö´ÐС£
ËäÈ»ÏÖÔÚÒѾӿÏÖ³öÁ ......
2005-2006ѧÄêµÚ1ѧÆÚ
±à Òë Ô Àí
¿Î ³Ì Éè ¼Æ ±¨ ¸æ
°à¼¶ 02¼Æ(¶þ)
ѧºÅ 19
ÐÕÃû ÁõÏþÃ÷
³É¼¨
Ö¸µ¼½Ìʦ ¬³¯»Ô
Ò»¡¢ Éè¼ÆÄ¿µÄ
¼ÓÉî¶Ô±àÒ ......
ÎÒÏȸøÒ»¸ö³õ²½µÄ±í¸ñ°É£¬´ó¼ÒÈç¹ûÓÐʲôÒâ¼û£¬»òÓв¹³ä£¬»¶ÓÌá³ö¡£ÓÐЩÎÒûÓÐÓùý£¬ÏȲ»Ð´ÁË¡£
ÒÔÏÂÊÇÎÒʹÓùýµÄpython IDE:
³ýÁËPythonWin, VisualPythonÖ»Ö§³ÖWindows£¬ÆäËü¶¼ÖÁÉÙÖ§³ÖWin/Linux/Mac¡£
¸÷ÏÒ壺
×Ô¶¯²¹È«£º±äÁ¿/º¯ÊýÃû´òµ½Ò»°ëʱ£¬Ìáʾ¿ÉÄܵÄÍêÕûµÄ±äÁ¿/º¯ÊýÃû¡ ......
You are here: Home ‣ Dive Into Python 3 ‣
Difficulty level: ♦♢♢♢♢
Installing Python °²×°Python
❝ Tempora mutantur nos et mutamur in illis. (Times change, and we change with them.) ❞
— ancient Roman proverb
D ......