File DB instead of real database?

Paul McNett p at ulmcnett.com
Sat Apr 14 00:30:30 EDT 2007


Jia Lu wrote:
>  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

-- 
pkm ~ http://paulmcnett.com




More information about the Python-list mailing list