나는 http://packages.python.org/CouchDB/mapping.html에서 CouchDb 튜토리얼을 따라 가고 있었다. 이것은 프로그램별로 모듈이 작동하지 않기 때문에 구식 인 것 같습니다. 그래서 저는 CouchDB python 스크립트를 작성하여 몇 가지 값만 저장했습니다. 여기에는 제 스크립트가 있습니다. 하지만 CouchDb 데이터베이스를 조회 할 때 이름과 나이를 찾을 수는 있지만 날짜 값은에 저장되지 않습니다. 누군가이 일을하는 법을 가르쳐 줄 수 있습니까? 또한 업데이트 된 python CouchDB 자습서가 있습니까?couchDB- 파이썬 날짜 값 저장
from couchdb import Server, Document
from couchdb.mapping import TextField, IntegerField, DateTimeField
import datetime
class Person(Document):
name = TextField()
age = IntegerField()
added = DateTimeField(default=datetime.datetime.now())
if __name__ == '__main__':
server = Server('http://localhost:5984')
try:
db = server.create('person')
except Exception:
db = server['person']
person = Person(name='John Doe', age=42)
db.save(person)
감사합니다. 어떻게하면 괄호를 제거하더라도 couchdb가 데이터를 표시하지 않습니다. – Rkz
새 레코드를 만들었습니까? 'default'는 새로운 Couchdb 레코드를 생성 할 때만 영향을 미칠 것입니다. –
db.save (person)는 새 레코드를 만들고,이 인수를 전달할 때부터 새 레코드에서 이름과 나이를 봅니다. – Rkz