Help for newbie

L

Leuk

I would like to use ZODB, but I'm a newbie in Python, so I do not know if it
be more easy for me to use PostgreSQL.
Some one can tell me what database will be better to use? What are de
differencies between this two databases?
Thanks very much :)
 
D

Diez B. Roggisch

Leuk said:
I would like to use ZODB, but I'm a newbie in Python, so I do not know if
it be more easy for me to use PostgreSQL.
Some one can tell me what database will be better to use? What are de
differencies between this two databases?

To use zodb after you installed it is a piece of cake. It goes along these
lines (they are from an actual project, so they aren't spiced up as proper
example code:)

db = ZODB.DB(ZODB.FileStorage.FileStorage(database))
conn = db.open()
dbroot = conn.root()

As dbroot is a dictionary-like object, you can start inserting arbitrary
objects there, as long as they extend from the class Persistent. There are
tutorials/examples out there, that will show you the neccessary stuff.

On the pro side, zodb is an object database - you can more or less stuff
everything in there, and retrieve it as objects again - no object
relational mapping and so on. Even complex object graphs can be stored, n:m
relations are simply modelled by python's list and dict types - actually,
there are some zodb-classes that you need to use for practical reasons, but
the interface is the well-known one you love form your common python
container objects ;)

You also don't need any server infrastructure.

The cons are to my POV:

- the more explicit data model of an rdbms like postgres allows for easier
migration. If your zodb storage contains objects of type foo, which you
then alter, it can happen that restored objects are not what you expect
them to be - they might miss data. While data migration is a matter in
rdbms too, its somewhat easier due to the simpler structure of the data.

- no builtin querying, let alone indexing. I've actually written my own
object query language (which is fun for starters, but gets tedious). So if
you are going to create much reports, zodb might not suit you so well. Of
course you can write all sorts of extensions - ZCatalog is a powerful
example - but in the end, you'll write a rdbms-like thingy on top of zodb.
then a rdbms might be the betteor choice in the first place. And there is
of course no shell-like interface to your db, as these are provided for the
rdbms out there.

- collisions after concurrent modifications can be a nasty thing - an the
docs are not to clear about what to do. It took me quite some time to solve
some issues with that.

- the advantage of no need for infrastructure can be a disadvantage of
course - as you have no model of acces rights on your data, you have to
somehow insure that yourself. Having said that, one has to keep in mind
that most database driven apps also only have one user for the connection.
I once tried to utilize the elaborated oracle user rights management, and
failed miserably - its a complicated endeavour.

While the cons seem to outweight the pros in sheer number, my personal exp.
is that at least for prototyping and from a pure programmers POV, ZODB
wins. Maybe if the project is mature enough, you can go and create
object2relational mappings - but through developement, things are nicer in
zodb.
 
D

Dave Cook

I would like to use ZODB, but I'm a newbie in Python, so I do not know if it
be more easy for me to use PostgreSQL.

They are quite different beasties. ZODB is an object database (based on
trees of objects), whereas Postgres is relational (based on tables). Using
ZODB with your own object model is fairly transparent, whereas with any SQL
database you have to write to and read from tables. However, there are
Object-Relation mappers for Python like SQLObject:

http://www.sqlobject.org

ZODB only provides the database "engine", whereas Postgres has both server
and client components. ZODB is much easier to set up than Postgres (really,
you just install ZODB and go; Postgres requires a little more administration
than that). ZODB provides no built-in indexing and query ability
AFAIK, so you may want to install something like IndexedCatalog:

http://www.async.com.br/projects/IndexedCatalog/

Dave Cook
 
L

Leuk

Thanks very much for your information
But I would like to know how I'll write and retreive my objets when my
system will be written in Java. At what time or how I'll switch to Python.
My system is intended to supervise a network and get objects (as processor
attributes, system attributes ...) and after I would like to save these
objects in an Object database (I think is more simple). Is for that I would
prefer to use ZODB. But is it possible?
Jean-Louis
 
D

Dave Cook

Thanks very much for your information
But I would like to know how I'll write and retreive my objets when my
system will be written in Java. At what time or how I'll switch to Python.

Are you planning on using Jython?

http://www.jython.org

In that case, you might want to find a Java solution that you can use with
Jython. I've used hibernate + hsql from Jython, but that may be overkill
for your application.

Dave Cook
 
J

Jean-Louis Nespoulous

Thank you very much, but I will use ZODB as a server, and from a
distance client I'll get and save objetcts with XML-RPC. Do you think
it will be ok?

Jean-Louis
 
D

Diez B. Roggisch

Jean-Louis Nespoulous said:
Thank you very much, but I will use ZODB as a server, and from a
distance client I'll get and save objetcts with XML-RPC. Do you think
it will be ok?

You can't get objects using xmlrpc. At least not over language-boundaries.
Of cours you can access your python server using xmlrpc, and if thats
sufficient, ok. But you can not pass a java object and expect it to be
stored in zodb.

And I personally wouldn't go for xmlrpc, but corba for java/python
interoperability, but thats of course a matter of taste.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,212
Messages
2,571,101
Members
47,695
Latest member
KayleneBee

Latest Threads

Top