Database and Interface for Python

Discussion in 'Python' started by Michael Foord, Oct 7, 2004.

  1. I'm writing a couple of modules that store information about user
    'behaviour'. E.g. a user accesses a certain page of a website at a
    certain date-time with a certain referrer.

    I need to analyse this information by different criteria. E.g. How
    many users accessed the website between August 5th and August 12th,
    listed by refferer !! etc It would be great to have a database engine
    where I could ask these questions in just a couple of queries, rather
    than having to implement all the sort/analyse functions myself.

    I guess this is as bad a time as anyto start to learn to use a
    database !! So I look on google and the situation is a little unclear.
    I can use the database API that will give me a 'consistent
    interface'... but I still need a database engine installed. e.g.
    MySQL. Not only that but I need a python interface to that engine that
    the database API can use ? (or I can just directly use the python
    binding for whichever database I pick ?).

    I think the web server I use will allow MySQL databases, so if I
    install it on my windoze box and install the MySQLdb python module
    then I'm well away....


    Have I got it right ? Can I do 'date range' queries using MySQL,
    MySQLdb and the Python database API ?

    Regards,


    Fuzzy

    http://www.voidspace.org.uk/atlantibots/pythonutils.html
     
    Michael Foord, Oct 7, 2004
    #1
    1. Advertisements

  2. Michael Foord

    Larry Bates Guest

    Michael Foord wrote:
    > I'm writing a couple of modules that store information about user
    > 'behaviour'. E.g. a user accesses a certain page of a website at a
    > certain date-time with a certain referrer.
    >
    > I need to analyse this information by different criteria. E.g. How
    > many users accessed the website between August 5th and August 12th,
    > listed by refferer !! etc It would be great to have a database engine
    > where I could ask these questions in just a couple of queries, rather
    > than having to implement all the sort/analyse functions myself.


    Yep, databases are fast, reliable and scalable for this.

    >
    > I guess this is as bad a time as anyto start to learn to use a
    > database !! So I look on google and the situation is a little unclear.
    > I can use the database API that will give me a 'consistent
    > interface'... but I still need a database engine installed. e.g.
    > MySQL. Not only that but I need a python interface to that engine that
    > the database API can use ? (or I can just directly use the python
    > binding for whichever database I pick ?).


    Python has a good DB interface to MySQL that works well.
    >
    > I think the web server I use will allow MySQL databases, so if I
    > install it on my windoze box and install the MySQLdb python module
    > then I'm well away....
    >
    >
    > Have I got it right ? Can I do 'date range' queries using MySQL,
    > MySQLdb and the Python database API ?


    Yes you can. Dates are stored in special format (not text) in the
    database that make searching/sorting possible. You can also define
    index on a date column and jump directly to a specific date (skipping
    all dates you don't want to process) or range of dates.

    >
    > Regards,
    >
    >
    > Fuzzy
    >
    > http://www.voidspace.org.uk/atlantibots/pythonutils.html
     
    Larry Bates, Oct 7, 2004
    #2
    1. Advertisements

  3. Michael Foord wrote:

    > I need to analyse this information by different criteria. E.g. How
    > many users accessed the website between August 5th and August 12th,
    > listed by refferer !! etc It would be great to have a database engine
    > where I could ask these questions in just a couple of queries, rather
    > than having to implement all the sort/analyse functions myself.


    Just simply transfer those your data to database and then retrievieng
    detailed information will be simple.

    > I guess this is as bad a time as anyto start to learn to use a
    > database !! So I look on google and the situation is a little unclear.
    > I can use the database API that will give me a 'consistent
    > interface'... but I still need a database engine installed. e.g.
    > MySQL. Not only that but I need a python interface to that engine that
    > the database API can use ?


    Yes, you will need both database and python interface to access it.


    > I think the web server I use will allow MySQL databases, so if I
    > install it on my windoze box and install the MySQLdb python module
    > then I'm well away....


    Webserwer has nothing to do with database.

    > Have I got it right ? Can I do 'date range' queries using MySQL,
    > MySQLdb and the Python database API ?


    Yes.

    --
    Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
    www.fiedzia.prv.pl
     
    Maciej Dziardziel, Oct 7, 2004
    #3
  4. On 7 Oct 2004 15:11:17 -0700, (Michael Foord)
    declaimed the following in comp.lang.python:


    > I can use the database API that will give me a 'consistent
    > interface'... but I still need a database engine installed. e.g.


    The "database API" is a specification of what a database
    specific interface module should implement for "consistent" access. It
    doesn't have a physical existence (you can't "import API").

    >
    > I think the web server I use will allow MySQL databases, so if I
    > install it on my windoze box and install the MySQLdb python module
    > then I'm well away....
    >

    MySQLdb is /a/ module that implements the "database API" for
    MySQL; there are many other modules that implement the "database API"
    for other database engines.

    >
    > Have I got it right ? Can I do 'date range' queries using MySQL,
    > MySQLdb and the Python database API ?
    >

    If you can do one using the command-line mysql client program,
    sure... Since all you do in a DB API compliant module is generate a
    string of the same SQL used in the command-line....

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Oct 8, 2004
    #4
  5. [snip..]
    > > I guess this is as bad a time as anyto start to learn to use a
    > > database !! So I look on google and the situation is a little unclear.
    > > I can use the database API that will give me a 'consistent
    > > interface'... but I still need a database engine installed. e.g.
    > > MySQL. Not only that but I need a python interface to that engine that
    > > the database API can use ?

    >
    > Yes, you will need both database and python interface to access it.
    >
    >
    > > I think the web server I use will allow MySQL databases, so if I
    > > install it on my windoze box and install the MySQLdb python module
    > > then I'm well away....

    >
    > Webserwer has nothing to do with database.
    >


    It does if it's a 'web application' your developing !! Whatever
    solution I choose has to work on my server *and* on my windoze nox for
    testing !!

    Thanks for your answer though.

    Regards,

    Fuzzy

    http://www.voidspace.org.uk/atlantibots/pythonutils.html

    > > Have I got it right ? Can I do 'date range' queries using MySQL,
    > > MySQLdb and the Python database API ?

    >
    > Yes.
     
    Michael Foord, Oct 8, 2004
    #5
  6. [snip..]
    > > I guess this is as bad a time as anyto start to learn to use a
    > > database !! So I look on google and the situation is a little unclear.
    > > I can use the database API that will give me a 'consistent
    > > interface'... but I still need a database engine installed. e.g.
    > > MySQL. Not only that but I need a python interface to that engine that
    > > the database API can use ? (or I can just directly use the python
    > > binding for whichever database I pick ?).

    >
    > Python has a good DB interface to MySQL that works well.
    > >


    Am I right in thinking that is the MySQLdb python interface at
    http://sourceforge.net/projects/mysql-python

    This supports versions of MySQL up to 4.0.... ??

    Thanks for your help.


    Regards,


    Fuzzy


    > > I think the web server I use will allow MySQL databases, so if I
    > > install it on my windoze box and install the MySQLdb python module
    > > then I'm well away....
    > >
    > >
    > > Have I got it right ? Can I do 'date range' queries using MySQL,
    > > MySQLdb and the Python database API ?

    >
    > Yes you can. Dates are stored in special format (not text) in the
    > database that make searching/sorting possible. You can also define
    > index on a date column and jump directly to a specific date (skipping
    > all dates you don't want to process) or range of dates.
    >
    > >
    > > Regards,
    > >
    > >
    > > Fuzzy
    > >
    > > http://www.voidspace.org.uk/atlantibots/pythonutils.html
     
    Michael Foord, Oct 8, 2004
    #6
  7. Michael Foord wrote:


    >> > I think the web server I use will allow MySQL databases, so if I
    >> > install it on my windoze box and install the MySQLdb python module
    >> > then I'm well away....

    >>
    >> Webserwer has nothing to do with database.
    >>

    >
    > It does if it's a 'web application' your developing !! Whatever
    > solution I choose has to work on my server *and* on my windoze nox for
    > testing !!


    You can use (almost) any web server with any database, they are separate
    components (except few non-popular integrated solutions), so your web
    server will allow you to use mysql.

    --
    Maciej "Fiedzia" Dziardziel (fiedzia (at) fiedzia (dot) prv (dot) pl)
    www.fiedzia.prv.pl
     
    Maciej Dziardziel, Oct 8, 2004
    #7
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. M.-A. Lemburg
    Replies:
    0
    Views:
    445
    M.-A. Lemburg
    Dec 6, 2004
  2. Wolfgang Keller
    Replies:
    6
    Views:
    8,783
    Wolfgang Keller
    Aug 15, 2005
  3. eGenix Team: M.-A. Lemburg
    Replies:
    0
    Views:
    316
    eGenix Team: M.-A. Lemburg
    Jun 16, 2008
  4. eGenix Team: M.-A. Lemburg
    Replies:
    0
    Views:
    286
    eGenix Team: M.-A. Lemburg
    Oct 1, 2008
  5. eGenix Team: M.-A. Lemburg

    ANN: eGenix mxODBC - ODBC Database Interface for Python 3.0.2

    eGenix Team: M.-A. Lemburg, Oct 15, 2008, in forum: Python
    Replies:
    0
    Views:
    423
    eGenix Team: M.-A. Lemburg
    Oct 15, 2008
  6. eGenix Team: M.-A. Lemburg
    Replies:
    0
    Views:
    310
    eGenix Team: M.-A. Lemburg
    Nov 12, 2008
  7. eGenix Team: M.-A. Lemburg

    ANN: eGenix mxODBC Connect - Python Database Interface 1.0.0

    eGenix Team: M.-A. Lemburg, Dec 2, 2008, in forum: Python
    Replies:
    0
    Views:
    345
    eGenix Team: M.-A. Lemburg
    Dec 2, 2008
  8. eGenix Team: M.-A. Lemburg

    ANN: eGenix mxODBC Connect 1.0.1 - Python Database Interface

    eGenix Team: M.-A. Lemburg, Mar 19, 2009, in forum: Python
    Replies:
    0
    Views:
    286
    eGenix Team: M.-A. Lemburg
    Mar 19, 2009
Loading...