web.py+sqliteдµÄ¼òµ¥ÁôÑÔ±¾
´úÂëºÜÂÒ£¬¶øÇÒûÓÐÓõ½Ä£°å£¬°Ñhtml´úÂë¸úPython´úÂë»ìÔÚÒ»ÆðÁË£¬¶øÇÒҲûÓÐÓõ½web.py±¾ÉíÌṩµÄÊý¾Ý¿â²Ù×÷Ä£¿é£¬¾ø¶Ô´Ö³¬µÄ´úÂ룡
ѧϰÁ˺ܶණÎ÷£¬Ê×Ïȵ±È»ÊÇweb.py£¬È»ºóÊÇsqlite£¬½ÓÏÂÀ´ÊÇtimeÄ£¿é——¿´À´Ò²Î¨Óв»¶ÏµÄʵ¼ù£¬²ÅÕæÕýÄܽø²½£¡
˵ʵÔڵģ¬Å¼Ñ§htmlµ½ÏÖÔÚÕâô¾Ã£¬»¹ÊÇ°ëÍ°Ë®£¬±¯¾çÁË£¡
01 #!/usr/bin/env python
02 #coding=utf-8
03
04 import os,web,time
05 import sqlite3 as db
06
07 urls = (
08 '/', 'hello',
09 '/add','add'
10 )
11
12 class hello:
13 def GET(self):
14 #ʵÀý»¯sqldb£¬È»ºó»ñÈ¡ÄÚÈÝ
15 s = ""
16 sdb = sqldb()
17 rec = sdb.cu.execute("""select * from msgs""")
18 dbre = sdb.cu.fetchall()
19 for i in dbre:
20 s = "<p>"+i[2]+" <span style=\"color: blue\">"+i[1]+' sad: '+r"</span>"+" <span style=\"color: gray\">"+i[3]+r"</span></p>" + s
21
22 sh = """
23 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML>
24 <HEAD><meta http-equiv="X-UA-Compatible" content
Ïà¹ØÎĵµ£º
½ñÌìºÜ×ÔÈ»µÄÔÚдSqlÓï¾äµÄʱºòÓÃÁËTop£¬Ò»¿ªÊ¼Ã»·¢ÏÖÎÊÌ⣬ÒòΪÎÒ´ÓÊý¾Ý¿â¶Á³öµÄÖµÕýºÃÊÇ0£¬¶øÎÒÏ°¹ß±äÁ¿¶¨ÒåµÄʱºòÒ²¶¼¸³Öµ0£¬¿ÉÊǵ½ÎÒ²»Òª0µÄʱºòÎҾͷ¢ÏÖÎÊÌâÁË¡£ºóÀ´²ÅÖªµÀ£¬¿É°®µÄСsqlite¾¹È»Óв»Ö§³ÖµÄsqlÓï·¨¡£
¡¡¡¡¿´µ½Ä³¸öÂÛ̳ÓиöÐÂÊÖÒ²·¢ÏÖÁËÕâ¸öÎÊÌâ²¢·¢ÌûÁË£¬ÏÂÃæһţÈ˵Ļظ´ÊÇ“topÊÇÄļҵĹؼü´Ê?s ......
±¾ÎÄÒÔÊý¾Ý¿âÖеÄÊý¾Ý±íUserInfoΪʵÀýչʾÊý¾Ý¿â±íµÄ´´½¨¼°Êý¾Ý¼Ç¼µÄ¼Èë¡£
#!/bin/sh
#variables definition
#database location
db=/conf/db
#
#create table userInfo
#name: User name
#passwd: Password
#Privilege: User privilege -- Administrator:0 Operator:1
#
echo "create table UserInfo(n ......
½ñÌìÓöµ½ÁËÂé·³£º
ÓÃEclipse±àÒëpythonÏòsqliteÊý¾Ý¿â²åÈëÊý¾Ý×ÜÊÇÌáʾ±àÂëµÄÎÊÌ⣬ÎÒÉèÖÃÁËEclipseµÄworkspaceÓÃutf-8±àÂ뻹ÊDz»ÐÐ
µ«ÊÇÓÃEclipseдµÄ³ÌÐò±£´æÔÙÓÃIDLE´ò¿ªÈ´ÄܱàÒ룬Ææ¹ÖÁË
ÎÒ¿¼Âǵ½¿ÉÄÜÊÇÅäÖõÄÔÒò£¬ÕÒÕÒ±éÁËËùÓеÄÅäÖ㬶¼Ã»ÓÐÎÊÌ⣬°üÀ¨¹¤³ÌÎļþ
×îºóÎÒÓÃxvi32´ò¿ ......
ÎÒÏÖÔÚҪʹÓÃSQLite3.0´´½¨Ò»¸öÊý¾Ý¿â£¬È»ºóÔÚÊý¾Ý¿âÖд´½¨Ò»¸ö±í¸ñ¡£
Ê×ÏÈÒªÒýÈëSQLite3.0µÄlib¿â¡£È»ºó°üº¬Í·Îļþ#import <sqlite3.h>
¡¾1¡¿´ò¿ªÊý¾Ý¿â£¬Èç¹ûûÓУ¬ÄÇô´´½¨Ò»¸ö
sqlite3* database_;
-(BOOL) open{
NSArray *paths = NSSearchPathForDirectoriesInDomai ......