#!/usr/bin/env python# _*_ conding:utf-8 _*_import sysimport osimport Timeimport datetimeimport mysqldbtoday=datetime.date.today () Oneday=datetime.timedelta (Days=1) Yesterday=today-onedayyes_last=datetime.datetime.strftime (Yesterday, "%y%m%d") #print yes_last#print c _timetry: conn1=mysqldb.connect (host= ' 192.168.1.108 ', user= ' Dlan ', passwd= ' root123 ', port= 3306,db= ' AA ') cur1 = conn1.cursor () aa2 = " Create table aa_ " + yes_last + " " + " as " + " " + "Select * from test" + " " + " where " + " " + " Date_format " + " (Ti, '%y%m%d ') " + " = " + yes_last old_del = "Delete from test" + " + where + " " + "Date_format" + "(Ti, '%y%m%d ')" + "=" + yes_ Last cur1.execute (AA2) cur1.execute (Old_del) conn1.commit () cur1.close () conn1.close () except mysqldb.error,e: print "Could not connect to mysql server ", E
This article is from the "DBSpace" blog, so be sure to keep this source http://dbspace.blog.51cto.com/6873717/1878674
Python play-to-character stitching