[Tutor] Python - Data Mining?

Eric Dorsey dorseye at gmail.com
Sun Jan 4 20:32:12 CET 2009


Hi Nick,
I don't know about the graphing portion of your question, but yes Python
does interact very well with databases. I have been working on a workout
tracking program the last two months or so, and I'm new to programming. I'd
highly recommend SQLite as a built-in database solution. I know it's
included in Python version 2.5 which is what i'm currently running. You can
call it at the top of your program with "import sqlite3", then you can run
queries and create tables, etc.

Here is some example code of SQLite usage in my program:

#create the database, or connect if it already exists
conn = sqlite3.connect('workoutstats.db')

#create a variable called cursor to use, since its easier than typing out
conn.cursor() all the time..
cursor = conn.cursor()

#create a table
cursor.execute('''
  CREATE TABLE WR (id INTEGER PRIMARY KEY, reps SMALLINT(1000),
  weight SMALLINT(1000), exer VARCHAR(30), date DATE)
  ''')

#query the WR table, feeding it the 'srch' variable which fills in where the
SQL has a ?
cursor.execute(
    "SELECT SUM(REPS) FROM WR WHERE EXER=?",
    (srch,)
    )

-Eric

On Sun, Jan 4, 2009 at 11:25 AM, Nick Scholtes <airchia at gmail.com> wrote:

> Hi,
> I'm still very, very new to Python and programming. I was wondering if
> anyone can point me in the right direction.
>
> As I gradually learn Python, one of the things I want to be able to do is
> take a database, run queries and extract information and then graph that
> information visually to see patterns in the data. Where should I start?
> Does Python do this? If not, what language is used for this?
>
> Thank you very much,
> Nick
>
>
> --
> Art: http://www.coroflot.com/bellsoffreedom
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
(e)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090104/10ebb484/attachment-0001.htm>


More information about the Tutor mailing list