Comments (4)
From cmlenz on November 05, 2008 09:02:34
This works for me. Please note that the database (represented by the db
variable in your example) does need
to exist. If it does, you should be able to create a document using either method. In fact db.create
is intended
for use when you want CouchDB to generate the ID for you.
Status: WorksForMe
from couchdb-python.
From [email protected] on November 05, 2008 10:26:31
In this example the Database "files" exists...
s = couchdb.Server("http://192.168.1.99:5984/"
db = s['files']
f = db['foo'] = "{'_id': 'hi', 'contents':'ho'}"
Traceback (most recent call last):
File "", line 1, in
File "/usr/lib/python2.5/site-packages/CouchDB-0.4-py2.5.egg/couchdb/client.py",
line 263, in setitem
File "/usr/lib/python2.5/site-packages/CouchDB-0.4-py2.5.egg/couchdb/client.py",
line 657, in put
File "/usr/lib/python2.5/site-packages/CouchDB-0.4-py2.5.egg/couchdb/client.py",
line 694, in _request
couchdb.client.ServerError: (500, (u'EXIT', u'{function_clause,[{cjson,tokenize,\n
["'_id': 'hi', 'contents':'ho'}",\n
{decoder,unicode,null,1,2,key}]},\n {cjson,decode_object,3},\n
{cjson,json_decode,2},\n
{couch_httpd,handle_doc_request,5},\n
{couch_httpd,handle_request,2},\n {mochiweb_http,headers,4},\n
{proc_lib,init_p,5}]}'))
from couchdb-python.
From cmlenz on November 05, 2008 13:52:52
The document needs to be a dict, not a JSON string. (I may need to add a check for this).
Also, when you use the item assignment syntax (instead of the create method), you must leave out the _id
member.
So:
f = db['hi'] = {'contents': 'ho'}
from couchdb-python.
From [email protected] on November 06, 2008 06:28:50
Fabtabulous!
Thanks so much! I think a check on a string input would be good but clearly I was
just doing it wrong! Also it makes sense I should have left off the "_id" part I
think I must have tried it from a .create() sample where I was trying to get the name
set.
Thanks again for build this library! I like couchdb but all the REST URLs are
confounding to me (especially when getting into views!).
from couchdb-python.
Related Issues (20)
- couchdb-dump: No python 3.5 support HOT 1
- `ViewResult` slicing with `datetime` object HOT 3
- Missing git tag for 1.1 HOT 1
- Support mango queries HOT 10
- HTTP basic auth is broken for accented characters HOT 2
- Server.version() broken for CouchDB 2.0 HOT 6
- Support CouchDB 2.0.0 HOT 10
- CouchDB 2.0 - syncing views make CouchDB hanging HOT 4
- Not url-encoding doc IDs in update handler call HOT 15
- Put Multiple Attachments HOT 1
- Bug when used with multiprocessing HOT 3
- `'_io.BytesIO' object is not subscriptable` when creating new document HOT 8
- More user friendly for HTTP Basic Auth HOT 2
- View Server Write Error: str, not bytes HOT 3
- config has moved in 2.0.0 HOT 4
- missing find() definition on Database class HOT 5
- [Mango query] Show warning when no matching index found. HOT 1
- Cant find a way to send headers in replication HOT 2
- End of Support ?= End Of Documentation HOT 2
- Cookie auth token error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from couchdb-python.