File DB instead of real database?

Pierre Quentel quentel.pierre at wanadoo.fr
Sat Apr 14 02:39:30 EDT 2007


On 14 avr, 06:14, "Jia Lu" <Roka... at gmail.com> wrote:
> Hello all
>
>  I donot want to use a real DB like MySQL ... But I need something to
> save about more than 1000 articles.
>  Is there any good ways?
>

Hi,

For small sets of data PyDbLite is a good alternative to full-blown db
engines

>>> import PyDbLite
>>> db = PyDbLite.Base("records").create('title','artist')
>>> db.insert('Ok Computer','Radiohead')
0
>>> db.insert('Night On Earth','Rialto')
1
>>> db.insert('Employment','Kaiser Chiefs')
2
>>> print [ r['title'] for r in db ]
['Ok Computer', 'Night On Earth', 'Employment']
>>> print [ r['artist'] for r in db if r['artist'].startswith('R') ]
['Radiohead', 'Rialto']
>>>

The syntax is intuitive for Python programmers (list comprehensions) ;
it's a single, small Python module downloable at
http://quentel.pierre.free.fr/PyDbLite/index.html

Regards,
Pierre




More information about the Python-list mailing list