File DB instead of real database?

J

Jia Lu

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?

Thanx

Jia Lu
 
P

Paul McNett

Jia said:
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?

(in Python 2.5):

#-- begin
import sqlite3.dbapi2 as sqlite

con = sqlite.connect("path/to/new/filename.db")
cur = con.cursor()
cur.executescript("""
create table articles (id integer primary key autoincrement,
name text,
content clob);
create index articles_name on articles (name);

insert into articles (name, clob)
values ("My new article", "Article text. blah blah");

""")

con.commit()

#-- end
 
R

Richard Jones

Jia said:
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?

import anydbm


Richard
 
P

Pierre Quentel

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
 
B

Bruno Desthuilliers

Jia Lu a e'crit :
Hello all

I donot want to use a real DB like MySQL ...

Whether MySQL is qualifies as a "real DB" is still an open question. But
you can use SQLite, which is an embedded SQL database.
 
S

Sebastian Bassi

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?

SQLite is a good option, as you were told. But what about put them in
a dictionary and then cPickle it to disk? (using 2 as optimization
setting in cPickle command).
 

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
473,780
Messages
2,569,611
Members
45,268
Latest member
AshliMacin

Latest Threads

Top