You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Adam Petty <ad...@gmail.com> on 2009/02/15 03:31:15 UTC

quick python / couch question

My appologies if this isn't the right place...and yes I'm a neub at things
both python and couch so I'll be greatly appreciative for any info
available.

I'm currently trying to get a python object to convert to a couch document
to submit to the DB - but can't seem to find a good way to do it.

for example:

Id like to convert the following python document:

{'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1), 'names':
{'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
'fname':'tim'}}

I'd like to write this directly to a couchDB - and I've tried jsonpickle,
and looked all through couchdb.schema, but again am new at python and couch.



I can see the dicts, and I know I can convert from a couchdoc to python
automatically -- what am I missing.

Again - thanks,

Adam

Re: quick python / couch question

Posted by David Pratt <fa...@gmail.com>.
Allan. there is a couchdb lib for twisted. Google should help you  
find this. It is basic though and without the features of clenz's  
couchdb lib. I am also a twisted fan btw.

Regards,
David


On Feb 16, 2009, at 2:37 PM, Alan Bell wrote:

> Has anyone given the twisted python library any love recently? last  
> time I checked it was almost growing attachment handling (as was  
> couchdb) or is there a way to do twisted type programming with  
> deferred events with the couchdb-python library.
>
> Alan.
>
> Jeff Hinrichs - DM&T wrote:
>> On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com>  
>> wrote:
>>
>>> My appologies if this isn't the right place...and yes I'm a neub  
>>> at things
>>> both python and couch so I'll be greatly appreciative for any info
>>> available.
>>>
>>> I'm currently trying to get a python object to convert to a couch  
>>> document
>>> to submit to the DB - but can't seem to find a good way to do it.
>>>
>>> for example:
>>>
>>> Id like to convert the following python document:
>>>
>>> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1),  
>>> 'names':
>>> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
>>> 'fname':'tim'}}
>>>
>>> I'd like to write this directly to a couchDB - and I've tried  
>>> jsonpickle,
>>> and looked all through couchdb.schema, but again am new at python  
>>> and couch.
>>>
>>>
>>>
>>> I can see the dicts, and I know I can convert from a couchdoc to  
>>> python
>>> automatically -- what am I missing.
>>>
>>> Again - thanks,
>>>
>>> Adam
>>>
>>>
>> Are you using the couchdb-python libary,
>> http://code.google.com/p/couchdb-python/ ?
>> Since you mention couchdb.schema, I assume that you are.  I would go
>> with the standard interface as suggested by Paul.
>>
>>
>> -Jeff
>>
>


Re: quick python / couch question

Posted by Alan Bell <al...@theopenlearningcentre.com>.
I was indeed talking about Paisley, I had forgotten what it was called. 
Offhand do you think it should still work with the current couchdb API? 
I think I will dig out my old code that was using it and see if I can 
push it on a bit.

Alan.

David Reid wrote:
> Hi Alan,
>
> Are you talking about Paisley or some other twisted python couchdb 
> library?
>
> If you're talking about Paisley the simple answer is that no one has 
> filed bugs against it and I haven't been using it so I haven't been 
> developing it.  If you're interested in adding features or fixing bugs 
> you're welcome to go to https://launchpad.net/~paisley-dev/+join and 
> join the Paisley Developers team.
>
> -David
>
> On Feb 16, 2009, at 10:37 AM, Alan Bell wrote:
>
>> Has anyone given the twisted python library any love recently? last 
>> time I checked it was almost growing attachment handling (as was 
>> couchdb) or is there a way to do twisted type programming with 
>> deferred events with the couchdb-python library.
>>
>> Alan.
>>
>> Jeff Hinrichs - DM&T wrote:
>>> On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com> 
>>> wrote:
>>>
>>>> My appologies if this isn't the right place...and yes I'm a neub at 
>>>> things
>>>> both python and couch so I'll be greatly appreciative for any info
>>>> available.
>>>>
>>>> I'm currently trying to get a python object to convert to a couch 
>>>> document
>>>> to submit to the DB - but can't seem to find a good way to do it.
>>>>
>>>> for example:
>>>>
>>>> Id like to convert the following python document:
>>>>
>>>> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1), 
>>>> 'names':
>>>> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
>>>> 'fname':'tim'}}
>>>>
>>>> I'd like to write this directly to a couchDB - and I've tried 
>>>> jsonpickle,
>>>> and looked all through couchdb.schema, but again am new at python 
>>>> and couch.
>>>>
>>>>
>>>>
>>>> I can see the dicts, and I know I can convert from a couchdoc to 
>>>> python
>>>> automatically -- what am I missing.
>>>>
>>>> Again - thanks,
>>>>
>>>> Adam
>>>>
>>>>
>>> Are you using the couchdb-python libary,
>>> http://code.google.com/p/couchdb-python/ ?
>>> Since you mention couchdb.schema, I assume that you are.  I would go
>>> with the standard interface as suggested by Paul.
>>>
>>>
>>> -Jeff
>>>
>>
>


Re: quick python / couch question

Posted by Adam Petty <ad...@gmail.com>.
I only have python-couchdb installed...


On Mon, Feb 16, 2009 at 1:47 PM, David Reid <dr...@dreid.org> wrote:

> Hi Alan,
>
> Are you talking about Paisley or some other twisted python couchdb library?
>
> If you're talking about Paisley the simple answer is that no one has filed
> bugs against it and I haven't been using it so I haven't been developing it.
>  If you're interested in adding features or fixing bugs you're welcome to go
> to https://launchpad.net/~paisley-dev/+join<https://launchpad.net/%7Epaisley-dev/+join>and join the Paisley Developers team.
>
> -David
>
>
> On Feb 16, 2009, at 10:37 AM, Alan Bell wrote:
>
>  Has anyone given the twisted python library any love recently? last time I
>> checked it was almost growing attachment handling (as was couchdb) or is
>> there a way to do twisted type programming with deferred events with the
>> couchdb-python library.
>>
>> Alan.
>>
>> Jeff Hinrichs - DM&T wrote:
>>
>>> On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com>
>>> wrote:
>>>
>>>  My appologies if this isn't the right place...and yes I'm a neub at
>>>> things
>>>> both python and couch so I'll be greatly appreciative for any info
>>>> available.
>>>>
>>>> I'm currently trying to get a python object to convert to a couch
>>>> document
>>>> to submit to the DB - but can't seem to find a good way to do it.
>>>>
>>>> for example:
>>>>
>>>> Id like to convert the following python document:
>>>>
>>>> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1),
>>>> 'names':
>>>> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
>>>> 'fname':'tim'}}
>>>>
>>>> I'd like to write this directly to a couchDB - and I've tried
>>>> jsonpickle,
>>>> and looked all through couchdb.schema, but again am new at python and
>>>> couch.
>>>>
>>>>
>>>>
>>>> I can see the dicts, and I know I can convert from a couchdoc to python
>>>> automatically -- what am I missing.
>>>>
>>>> Again - thanks,
>>>>
>>>> Adam
>>>>
>>>>
>>>>  Are you using the couchdb-python libary,
>>> http://code.google.com/p/couchdb-python/ ?
>>> Since you mention couchdb.schema, I assume that you are.  I would go
>>> with the standard interface as suggested by Paul.
>>>
>>>
>>> -Jeff
>>>
>>>
>>
>

Re: quick python / couch question

Posted by David Reid <dr...@dreid.org>.
Hi Alan,

Are you talking about Paisley or some other twisted python couchdb  
library?

If you're talking about Paisley the simple answer is that no one has  
filed bugs against it and I haven't been using it so I haven't been  
developing it.  If you're interested in adding features or fixing bugs  
you're welcome to go to https://launchpad.net/~paisley-dev/+join and  
join the Paisley Developers team.

-David

On Feb 16, 2009, at 10:37 AM, Alan Bell wrote:

> Has anyone given the twisted python library any love recently? last  
> time I checked it was almost growing attachment handling (as was  
> couchdb) or is there a way to do twisted type programming with  
> deferred events with the couchdb-python library.
>
> Alan.
>
> Jeff Hinrichs - DM&T wrote:
>> On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com>  
>> wrote:
>>
>>> My appologies if this isn't the right place...and yes I'm a neub  
>>> at things
>>> both python and couch so I'll be greatly appreciative for any info
>>> available.
>>>
>>> I'm currently trying to get a python object to convert to a couch  
>>> document
>>> to submit to the DB - but can't seem to find a good way to do it.
>>>
>>> for example:
>>>
>>> Id like to convert the following python document:
>>>
>>> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1),  
>>> 'names':
>>> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
>>> 'fname':'tim'}}
>>>
>>> I'd like to write this directly to a couchDB - and I've tried  
>>> jsonpickle,
>>> and looked all through couchdb.schema, but again am new at python  
>>> and couch.
>>>
>>>
>>>
>>> I can see the dicts, and I know I can convert from a couchdoc to  
>>> python
>>> automatically -- what am I missing.
>>>
>>> Again - thanks,
>>>
>>> Adam
>>>
>>>
>> Are you using the couchdb-python libary,
>> http://code.google.com/p/couchdb-python/ ?
>> Since you mention couchdb.schema, I assume that you are.  I would go
>> with the standard interface as suggested by Paul.
>>
>>
>> -Jeff
>>
>


Re: quick python / couch question

Posted by Alan Bell <al...@theopenlearningcentre.com>.
Has anyone given the twisted python library any love recently? last time 
I checked it was almost growing attachment handling (as was couchdb) or 
is there a way to do twisted type programming with deferred events with 
the couchdb-python library.

Alan.

Jeff Hinrichs - DM&T wrote:
> On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com> wrote:
>   
>> My appologies if this isn't the right place...and yes I'm a neub at things
>> both python and couch so I'll be greatly appreciative for any info
>> available.
>>
>> I'm currently trying to get a python object to convert to a couch document
>> to submit to the DB - but can't seem to find a good way to do it.
>>
>> for example:
>>
>> Id like to convert the following python document:
>>
>> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1), 'names':
>> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
>> 'fname':'tim'}}
>>
>> I'd like to write this directly to a couchDB - and I've tried jsonpickle,
>> and looked all through couchdb.schema, but again am new at python and couch.
>>
>>
>>
>> I can see the dicts, and I know I can convert from a couchdoc to python
>> automatically -- what am I missing.
>>
>> Again - thanks,
>>
>> Adam
>>
>>     
> Are you using the couchdb-python libary,
> http://code.google.com/p/couchdb-python/ ?
> Since you mention couchdb.schema, I assume that you are.  I would go
> with the standard interface as suggested by Paul.
>
>
> -Jeff
>   


Re: quick python / couch question

Posted by Adam Petty <ad...@gmail.com>.
I very much appreciate it ... thank you

I thought I tried that, and got a "cannot convert (<datevalue>)" to json...
I figured out that I can convert using jsonpickle and then do a db.save in
that case...but I probably tried to use update or doc.store

Flying by the seat of my pants with 3 weeks python experience getting a
proof of concept so we can use CouchDB as our main datasource.

So thanks again!

- Adam

Flying by the seat of my pants getting a prototype together - thanks very
much for the help

On Sun, Feb 15, 2009 at 3:36 PM, Jeff Hinrichs - DM&T <du...@gmail.com>wrote:

> On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com> wrote:
> > My appologies if this isn't the right place...and yes I'm a neub at
> things
> > both python and couch so I'll be greatly appreciative for any info
> > available.
> >
> > I'm currently trying to get a python object to convert to a couch
> document
> > to submit to the DB - but can't seem to find a good way to do it.
> >
> > for example:
> >
> > Id like to convert the following python document:
> >
> > {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1), 'names':
> > {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
> > 'fname':'tim'}}
> >
> > I'd like to write this directly to a couchDB - and I've tried jsonpickle,
> > and looked all through couchdb.schema, but again am new at python and
> couch.
> >
> >
> >
> > I can see the dicts, and I know I can convert from a couchdoc to python
> > automatically -- what am I missing.
> >
> > Again - thanks,
> >
> > Adam
> >
> Are you using the couchdb-python libary,
> http://code.google.com/p/couchdb-python/ ?
> Since you mention couchdb.schema, I assume that you are.  I would go
> with the standard interface as suggested by Paul.
>
>
> -Jeff
>

Re: quick python / couch question

Posted by Jeff Hinrichs - DM&T <du...@gmail.com>.
On Sat, Feb 14, 2009 at 8:31 PM, Adam Petty <ad...@gmail.com> wrote:
> My appologies if this isn't the right place...and yes I'm a neub at things
> both python and couch so I'll be greatly appreciative for any info
> available.
>
> I'm currently trying to get a python object to convert to a couch document
> to submit to the DB - but can't seem to find a good way to do it.
>
> for example:
>
> Id like to convert the following python document:
>
> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1), 'names':
> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
> 'fname':'tim'}}
>
> I'd like to write this directly to a couchDB - and I've tried jsonpickle,
> and looked all through couchdb.schema, but again am new at python and couch.
>
>
>
> I can see the dicts, and I know I can convert from a couchdoc to python
> automatically -- what am I missing.
>
> Again - thanks,
>
> Adam
>
Are you using the couchdb-python libary,
http://code.google.com/p/couchdb-python/ ?
Since you mention couchdb.schema, I assume that you are.  I would go
with the standard interface as suggested by Paul.


-Jeff

Re: quick python / couch question

Posted by Paul Davis <pa...@gmail.com>.
Adam,

This should be as simple as:

import couchdb
server = couchdb.Server("http://127.0.0.1:5984")
db = server.create("test_db")
data = create_my_data_object()
db.save(data)
# or with a specified docid
db["my_docid"] = data

HTH,
Paul Davis

On Sat, Feb 14, 2009 at 9:31 PM, Adam Petty <ad...@gmail.com> wrote:
> My appologies if this isn't the right place...and yes I'm a neub at things
> both python and couch so I'll be greatly appreciative for any info
> available.
>
> I'm currently trying to get a python object to convert to a couch document
> to submit to the DB - but can't seem to find a good way to do it.
>
> for example:
>
> Id like to convert the following python document:
>
> {'username':'johnsmith','date'":(2009, 1, 1, 0, 0, 0, 3, 1, -1), 'names':
> {'lname':'smith','birtdate':(1974, 1, 20, 0, 0, 0, 3, 1, -1),
> 'fname':'tim'}}
>
> I'd like to write this directly to a couchDB - and I've tried jsonpickle,
> and looked all through couchdb.schema, but again am new at python and couch.
>
>
>
> I can see the dicts, and I know I can convert from a couchdoc to python
> automatically -- what am I missing.
>
> Again - thanks,
>
> Adam
>