any complete and actual pysqlite example?

oyster lepto.python at gmail.com
Sat Apr 18 08:59:00 EDT 2009


I mean not a code to do seperated functions, but a real project

I have read the doc of pysqlite, but since I know little about
database, I found it is still very hard for me to cook a real database
app from the scratch with the help of codelet in pysqlite doc. here is
the simplified details:
[TABLE 1]
bookName text
price num
author <-- this is actually linked with the [TABLE 2], for one author
maybe write many books, I think it is better to do an external link
[/TABLE 1]

[TABLE 2]
authorName text
[/TABLE 2]

Then
[record  for TABLE 1]
id  bookName                          price authoridx
1   The Definitive Guide to SQLite      30      1
2   Core Python                         40      2
3   Dive Into Python                    35      3
[/record  for TABLE 1]

[record  for TABLE 2]
id  authorName
1   Michael Owens
2   Wesley J. Chun
3   Mark Pilgrim
[/record  for TABLE 2]

what I need
1. of cause, create the TABLE, and add real data into it. I don't know
how to deal with the author item in [TABLE 1]

2. list the data. A question is, when I list the record in [TABLE 1],
can I get something like following?
"The Definitive Guide to SQLite", 30.0, "Michael Owens"
I mean, the authorName is returned automatically, but not only the authoridx

3. what if I del the 1st record in [TABLE 2] since a record in [TABLE 1] use it?

4.I want to do some group, for example, group the record in [TABLE 1]
according to their price, so that
[30]
   Book1Name
   Book2Name
[40]
   Book3Name
[50]
   Book4Name
   Book4Name
does sqlite support this? or I have to do this in python?

thanx



More information about the Python-list mailing list