mysql - I can't insert stock's data into my database -


def connect(date1,volumn1,price1,rise1,time1):     #print type(date1),volumn1,price1,rise1,time1     db=mysqldb.connect("localhost","root","998426","stock")     cursor=db.cursor()     sql=" insert tab1(date,volumn,price,rise,time) values(%s,%s,%f,%s,%s)"%(date1,volumn1,price1,rise1,time1)     #sql = "insert tab1(date,volumn,price,rise,time) values('2017/9/13 星期二','200',17.5,'2.14%','15:30')"    //this can work!     try:         cursor.execute(sql)         db.commit()     except:         db.rollback()     db.close() 

date1,volumn1,rise1,time1 string;

price1 float;

    sql="insert stock_cb(dates,volumn,price,rise,times) values('%s','%s',%f,'%s','%s')" % (date1.encode("utf-8"),volumn1.encode("utf-8"),price1,rise1.encode("utf-8"),time1.encode("utf-8")) 

it can work when change it.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -