issue

Tim Chase python.list at tim.thechases.com
Mon Jan 19 06:16:33 EST 2009


> I started programing with python and want to use a suitable 
> database.But I Know nothing about them.please introduse one to
> me. thanks.

Since you're just starting out, I'd just use the built-in (as of 
Python2.5) sqlite

  >>> import sqlite3
  >>> c = sqlite3.connect('tmp/test.db')
  >>> cur = c.cursor()
  >>> cur.execute('create table test(id int primary key)')
  <sqlite3.Cursor object at 0xb7d72a70>
  >>> cur.execute('insert into test values (42)')
  <sqlite3.Cursor object at 0xb7d72a70>
  >>> cur.execute('insert into test values (3141)')
  <sqlite3.Cursor object at 0xb7d72a70>
  >>> cur.execute('select * from test')
  <sqlite3.Cursor object at 0xb7d72a70>
  >>> cur.fetchall()
  [(42,), (3141,)]

That will allow you to experiment.  You can later scale up to 
something like a MySQL, PostgreSQL or some other DB connector.

-tkc







More information about the Python-list mailing list