I
Ian Hobson
Hi all,
I have hit a problem and I don't know enough about python to diagnose
things further. Trying to use couchDB from Python. This script:-
# coding=utf8
import couchdb
from couchdb.client import Server
server = Server()
dbName = 'python-tests'
try:
db = server.create(dbName)
except couchdb.PreconditionFailed:
del server[dbName]
db = server.create(dbName)
doc_id, doc_rev = db.save({'type': 'Person', 'name': 'John Doe'})
Gives this traceback:-
D:\work\C-U-B>python tes1.py
Traceback (most recent call last):
File "tes1.py", line 11, in <module>
doc_id, doc_rev = db.save({'type': 'Person', 'name': 'John Doe'})
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\client.py",
line 407, in save
_, _, data = func(body=doc, **options)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 399, in post_json
status, headers, data = self.post(*a, **k)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 381, in post
**params)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 419, in _request
credentials=self.credentials)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 310, in request
raise ServerError((status, error))
couchdb.http.ServerError: (400, ('bad_request', 'invalid UTF-8 JSON'))
D:\work\C-U-B>
Why? I've tried adding u to the strings, and removing the # coding line,
and I still get the same error.
Thanks for any help.
Ian
I have hit a problem and I don't know enough about python to diagnose
things further. Trying to use couchDB from Python. This script:-
# coding=utf8
import couchdb
from couchdb.client import Server
server = Server()
dbName = 'python-tests'
try:
db = server.create(dbName)
except couchdb.PreconditionFailed:
del server[dbName]
db = server.create(dbName)
doc_id, doc_rev = db.save({'type': 'Person', 'name': 'John Doe'})
Gives this traceback:-
D:\work\C-U-B>python tes1.py
Traceback (most recent call last):
File "tes1.py", line 11, in <module>
doc_id, doc_rev = db.save({'type': 'Person', 'name': 'John Doe'})
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\client.py",
line 407, in save
_, _, data = func(body=doc, **options)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 399, in post_json
status, headers, data = self.post(*a, **k)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 381, in post
**params)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 419, in _request
credentials=self.credentials)
File
"C:\Python27\lib\site-packages\couchdb-0.8-py2.7.egg\couchdb\http.py",
line 310, in request
raise ServerError((status, error))
couchdb.http.ServerError: (400, ('bad_request', 'invalid UTF-8 JSON'))
D:\work\C-U-B>
Why? I've tried adding u to the strings, and removing the # coding line,
and I still get the same error.
Thanks for any help.
Ian