SORU
16 Temmuz 2009, PERŞEMBE


Python datetime ekleme.mysql datetime nesnesi

Mysql bir tabloda bir tarih sütunu var. Bu sütuna datetime.datetime() bir nesne eklemek istiyorum. Ben kullanarak deyimini yürütün ne yapmalıyım? Denedim:

now = datetime.datetime(2009,5,5)

cursor.execute("INSERT INTO table
(name, id, datecolumn) VALUES (%s, %s
, %s)",("name", 4,now))

Gibi bir hata alıyorum: "TypeError: not all arguments converted during string formatting" I %s yerine kullanılır.

CEVAP
22 Aralık 2010, ÇARŞAMBA


import time    
time.strftime('%Y-%m-%d %H:%M:%S')

Zaman alanı için. Strftime da datetime geçerli olduğunu düşünüyorum.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • AllYourNewsByMe

    AllYourNewsB

    18 Temmuz 2011
  • Call Me Howard

    Call Me Howa

    18 AĞUSTOS 2012
  • Google Россия

    Google Ро

    9 Temmuz 2007