2013年4月24日

摘要: args=['A', 'C']sql='SELECT fooid FROM foo WHERE bar IN (%s)' in_p=', '.join(list(map(lambda x: '%s', args)))sql = sql % in_pcursor.execute(sql, args) 阅读全文
posted @ 2013-04-24 17:24 Harveyaot 阅读(336) 评论(0) 推荐(0)
摘要: MySQLdb默认查询结果都是返回tuple,输出时候不是很方便,必须按照0,1这样读取,无意中在网上找到简单的修改方法,就是传递一个cursors.DictCursor就行。默认程序:import MySQLdbdb = MySQLdb.connect(host = 'localhost', user = 'root', passwd = '123456', db = 'test')cursor = db.cursor()cursor.execute('select * from user')rs = curso 阅读全文
posted @ 2013-04-24 17:14 Harveyaot 阅读(219) 评论(0) 推荐(0)

2013年4月18日

摘要: //div[@class="STYLE5"]//following::tr[position() =1]/td[2]//当前节点开始了,不再是/ 这样的按照层次下去的。/是绝对路径。 阅读全文
posted @ 2013-04-18 09:43 Harveyaot 阅读(346) 评论(0) 推荐(0)

2013年4月16日

摘要: it probably means that your MySQL server is only listening the localhost interface.If you have lines like this :skip-networkingbind-address =127.0.0.1In your my.cnf configuration file, you should comment them(add a # at the beginning of the lines), and restart MySQL.Of course, to do this, you must b 阅读全文
posted @ 2013-04-16 18:39 Harveyaot 阅读(205) 评论(0) 推荐(0)

2013年4月15日

摘要: 1 import smtplib 2 3 from email.mime.multipart import MIMEMultipart 4 from email.mime.text import MIMEText 5 6 # me == my email address 7 # you == recipient's email address 8 me = "my@email.com" 9 you = "your@email.com"10 11 # Create message container - the correct MIME type 阅读全文
posted @ 2013-04-15 18:01 Harveyaot 阅读(247) 评论(0) 推荐(0)

2013年4月10日

摘要: 从数据源:mysqldump -h -u -p database > local.sql(file)到目标机器mysqldump -h -u -p target_database < local.sql可能造成的问题是,新的数据库中,target_database 的表结构已经好了,但是需要再次进入到使用mysql 指令进入target 机器中。使用source local.sql命令进行数据的拷贝。 阅读全文
posted @ 2013-04-10 15:20 Harveyaot 阅读(181) 评论(0) 推荐(0)

2013年4月7日

摘要: 在crontab 中运行脚本,一定注意路径的问题,否则容易open file error即使和脚本在同一个目录下,有些资源文件也会出现问题。解决办法:可以在脚本中添加cd 到该目录。 阅读全文
posted @ 2013-04-07 09:36 Harveyaot 阅读(644) 评论(0) 推荐(0)

2013年4月3日

摘要: DROP TABLESyntaxDROP [TEMPORARY] TABLE [IF EXISTS] tbl_name [, tbl_name] ... [RESTRICT | CASCADE]1,drop table if exist2,myisam 和 inodb 的区别。 阅读全文
posted @ 2013-04-03 10:29 Harveyaot 阅读(159) 评论(0) 推荐(0)

2013年4月2日

摘要: 1 #!/bin/bash 2 f=$1 3 d=$2 4 # 20121212 5 6 if [ "${f}" == "" ]; then 7 f="/application/search/sitedb/out.map."`date "+%Y%m%d"` 8 fi 9 if [ "${d}" == "" ]; then10 d=`date "+%Y%m%d %H:%M:%S"`11 fi12 echo $d13 do=${d:0:8}14 15 echo 阅读全文
posted @ 2013-04-02 14:23 Harveyaot 阅读(566) 评论(0) 推荐(0)

2013年3月26日

摘要: 1,tuple 的多赋值 (a,b,c) = c,d,e2,ls = [i for i in range(10)] str = ["%s = %s" %(key ,value ) for key, value in ]3,getattr() 函数,ex:getattr([],'pop')4,可以使用 ["%s"%format]来做字符串的替换。5,lambda 函数没有 函数名字6,and-or 技巧 可以 充当c中的 bool?a:b ex:1 a = "a"2 b = "b"3 1 and a 阅读全文
posted @ 2013-03-26 23:10 Harveyaot 阅读(164) 评论(0) 推荐(0)

导航