HTTP server + SQLite?

Discussion in 'Python' started by Gilles Ganault, May 3, 2010.

  1. Hello

    I'd like to build a prototype that will combine a web server as
    front-end (it must support GZIPping data to the remote client when
    there are a lot of data to return), and SQLite as back-end, call the
    server from a VB.Net application, and see how well this works. I want
    to see if performance is significantly lower than using a server that
    uses a binary protocol.

    I'm no Python expert, so would appreciate any information on how to
    combine a web server and SQLite into a single Python application. This
    is just for a proof-of-concept, so it doesn't need to be
    shipping-quality.

    Thank you for any hint.
     
    Gilles Ganault, May 3, 2010
    #1
    1. Advertising

  2. Gilles Ganault

    alex23 Guest

    Gilles Ganault <> wrote:
    > I'm no Python expert, so would appreciate any information on how to
    > combine a web server and SQLite into a single Python application.


    Hey Gilles,

    I'm a fan of the http framework, CherryPy[1]. Very quick and easy to
    get something up and running. The site also has some ideas on
    interoperating with a database[2], although this might be a better
    starting point[3]. SQLite is included in the Python standard library
    past 2.5, but if you're stuck with either 2.3 or 2.4, the 3rd party
    library pysqlite[4] provides support for them.

    For a higher level web framework, I find Turbogears 2.x[5] really
    straightforward. It's based around SQLAlchemy, which supports SQLite,
    but sounds like it's probably overkill for your situation.

    1: http://www.cherrypy.org/
    2: http://tools.cherrypy.org/wiki/Databases
    3: http://code.activestate.com/recipes/496799/
    4: http://code.google.com/p/pysqlite
    5: http://turbogears.org/2.0/
     
    alex23, May 3, 2010
    #2
    1. Advertising

  3. Gilles Ganault

    Chris Rebert Guest

    On Mon, May 3, 2010 at 12:46 AM, Gilles Ganault <> wrote:
    > I'd like to build a prototype that will combine a web server as
    > front-end (it must support GZIPping data to the remote client when
    > there are a lot of data to return), and SQLite as back-end, call the
    > server from a VB.Net application, and see how well this works. I want
    > to see if performance is significantly lower than using a server that
    > uses a binary protocol.
    >
    > I'm no Python expert, so would appreciate any information on how to
    > combine a web server and SQLite into a single Python application. This
    > is just for a proof-of-concept, so it doesn't need to be
    > shipping-quality.


    If your want to write a basic/low-level HTTP server:
    http://docs.python.org/library/basehttpserver.html
    Looks like you'd use HTTPServer and a custom subclass of BaseHTTPRequestHandler.

    If you want to write at the slightly higher WSGI
    (http://www.python.org/dev/peps/pep-0333/) level of abstraction, you
    can have your WSGI application run by a simple Python HTTP server such
    as:
    http://pythonpaste.org/modules/httpserver.html

    As Alex said, SQLite is in the std lib:
    http://docs.python.org/library/sqlite3

    Cheers,
    Chris
    --
    http://blog.rebertia.com
     
    Chris Rebert, May 3, 2010
    #3
  4. On 05/03/10 09:46, Gilles Ganault wrote:
    > Hello
    >
    > I'd like to build a prototype that will combine a web server as
    > front-end (it must support GZIPping data to the remote client when
    > there are a lot of data to return), and SQLite as back-end, call the
    > server from a VB.Net application, and see how well this works. I want
    > to see if performance is significantly lower than using a server that
    > uses a binary protocol.
    >
    > I'm no Python expert, so would appreciate any information on how to
    > combine a web server and SQLite into a single Python application. This
    > is just for a proof-of-concept, so it doesn't need to be
    > shipping-quality.
    >


    You might have a look at
    http://www.karrigell.fr/doc/

    Helmut.

    --
    Helmut Jarausch

    Lehrstuhl fuer Numerische Mathematik
    RWTH - Aachen University
    D 52056 Aachen, Germany
     
    Helmut Jarausch, May 3, 2010
    #4
  5. Gilles Ganault

    Nat Guest

    interesting







     
    Nat, May 3, 2010
    #5
  6. Gilles Ganault, May 3, 2010
    #6
  7. Gilles Ganault

    lbolla Guest

    On May 3, 8:46 am, Gilles Ganault <> wrote:
    > Hello
    >
    > I'd like to build a prototype that will combine a web server as
    > front-end (it must support GZIPping data to the remote client when
    > there are a lot of data to return), and SQLite as back-end, call the
    > server from a VB.Net application, and see how well this works. I want
    > to see if performance is significantly lower than using a server that
    > uses a binary protocol.
    >
    > I'm no Python expert, so would appreciate any information on how to
    > combine a web server and SQLite into a single Python application. This
    > is just for a proof-of-concept, so it doesn't need to be
    > shipping-quality.
    >
    > Thank you for any hint.


    I quite like web.py: http://webpy.org/
    L.
     
    lbolla, May 3, 2010
    #7
  8. Gilles Ganault

    John Nagle Guest

    Gilles Ganault wrote:
    > Hello
    >
    > I'd like to build a prototype that will combine a web server as
    > front-end (it must support GZIPping data to the remote client when
    > there are a lot of data to return), and SQLite as back-end, call the
    > server from a VB.Net application, and see how well this works. I want
    > to see if performance is significantly lower than using a server that
    > uses a binary protocol.
    >
    > I'm no Python expert, so would appreciate any information on how to
    > combine a web server and SQLite into a single Python application. This
    > is just for a proof-of-concept, so it doesn't need to be
    > shipping-quality.
    >
    > Thank you for any hint.


    There's no reason you can't do that. Whether you want to is another issue.
    There are, after all, plenty of web servers out there. Also, SQLite really
    is a "lite" database. Although there's good read concurrency, multiple
    updates from multiple processes tend to result in sizable delays, since
    the locking is via file locks and wait/retry logic.

    John Nagle
     
    John Nagle, May 4, 2010
    #8
  9. Gilles Ganault

    Bryan Guest

    John Nagle wrote:
    > [...] SQLite really
    > is a "lite" database.  Although there's good read concurrency, multiple
    > updates from multiple processes tend to result in sizable delays, since
    > the locking is via file locks and wait/retry logic.


    True, and I have other gripes about SQLite, but I've fallen in love
    with it. SQLite rocks. SQLite rocks like Python rocks. Hard as Python
    had rocked before, Python started rockin' a whole bunch harder when
    2.5 included SQLite3 in the standard library.

    I love SQLite because it solves problems I actually have. For the vast
    majority of code I write, "lite" is a good thing, and lite as it is,
    SQLite can handle several transactions per second. I give SQLite a
    file path and in a split second I have a relational, transactional
    database. Great. I did not want to configure a server and I sure did
    not want to inflict complexity upon my users.

    If you are smart and/or lucky enough to write a web app so popular
    that it outgrows SQLite, you can switch over to a big-time SQL server
    DBMS. At worst, you'll have to tweak some of the code. Imagine how
    much harder the scaling problem would be if the persistent data were
    stored via pickle.

    The SQLite developers state the situation brilliantly at
    http://www.sqlite.org/whentouse.html:

    "SQLite is not designed to replace Oracle. It is designed to replace
    fopen()."


    --
    --Bryan
     
    Bryan, May 4, 2010
    #9
  10. On Mon, 3 May 2010 23:07:08 -0700 (PDT), Bryan
    <> wrote:
    >I love SQLite because it solves problems I actually have. For the vast
    >majority of code I write, "lite" is a good thing, and lite as it is,
    >SQLite can handle several transactions per second. I give SQLite a
    >file path and in a split second I have a relational, transactional
    >database. Great. I did not want to configure a server and I sure did
    >not want to inflict complexity upon my users.


    Exactly. I need a safe way to share an SQLite database among a few
    years, but sharing a drive isn't safe but I also don't need a
    full-fledged DBMS like MySQL.

    At this point, as an alternative to a Python-based solution, it seems
    like Mongoose + Lua + SQLite could do the trick.
     
    Gilles Ganault, May 4, 2010
    #10
  11. Gilles Ganault

    Terry Reedy Guest

    On 5/4/2010 2:07 AM, Bryan wrote:

    > The SQLite developers state the situation brilliantly at
    > http://www.sqlite.org/whentouse.html:


    For future reference, that link does not work with Thunderbird. This one
    does.

    http://www.sqlite.org/whentouse.html

    When posting links, best to put them on a line by themselves, with NO
    punctuation, even if 'proper' English seems to require it. A space
    before the colon probably would have worked too, if its complete absence
    bothers one too much ;=).

    Terry Jan Reedy
     
    Terry Reedy, May 4, 2010
    #11
    1. Advertising

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. larkpics
    Replies:
    9
    Views:
    9,038
    Patrick.O.Ige
    Oct 22, 2005
  2. Replies:
    3
    Views:
    817
    Guillermo
    Apr 26, 2007
  3. lkcl
    Replies:
    6
    Views:
    1,068
  4. Carl Youngblood
    Replies:
    1
    Views:
    235
    Carl Youngblood
    Apr 9, 2005
  5. Replies:
    4
    Views:
    356
Loading...

Share This Page