Python and databases. Good enough is sometimes best

With Django sub forum.
Post Reply
KBleivik
Site Admin
Posts: 184
Joined: Tue Sep 29, 2009 6:25 pm
Location: Moss Norway
Contact:

Python and databases. Good enough is sometimes best

Post by KBleivik »

1. Make it simple.

If you have some experience in using Python, you may know that the minimalistic SQL database platform sqlite http://www.sqlite.org/ comes as a standalone file with your Python installation. For some simple soultions SQLite is good enough. If you are mining text documents, there may be even better solutions like CouchDB.
Apache CouchDB is a document-oriented database that can be queried and indexed using JavaScript in a MapReduce fashion. CouchDB also offers incremental replication with bi-directional conflict detection and resolution.

CouchDB provides a RESTful JSON API than can be accessed from any environment that allows HTTP requests. There are myriad third-party client libraries that make this even easier from your programming language of choice. CouchDB’s built in Web administration console speaks directly to the database using HTTP requests issued from your browser.
Source: http://couchdb.apache.org/

or even simpler Redis
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
Source: http://redis.io/

A key - value combinantion? Can that be all you need? Ask yourself.

2. Don't use a canon to shoot sparrows. But security ...

The canons are of course proprietary data base platforms like Oracle, Sybase, MS SQL and similar proprietary platfroms. Many companies prefer free platforms like MySQL and PostGreSQL. Security is of course a concern, but don't fool yourself to think that your solution is secure enough:

Is your online password protected database on a secure server really secure?

No platform can compensate for bad programming and insecure code. An obvious example is php where a use of prepared statements and the PDO data base object can be sufficient for some tasks. Study the code in this http://www.oopschool.com/books/ProPHP6Example.pdf document where an effecient (object relational) mapping between a PostGreSQL database and your web application is described.

Of course, if you need a large and efficient, secure platform where monitoring the network traffic to and from the database is important, the best solution may be a proprietary platform.

3. Litterature and links

http://www.zodb.org/en/latest/

http://pythonhosted.org/Flask-ZODB/

http://www.postgresql.org/

http://www.mysql.com/

http://guide.couchdb.org/

http://guide.couchdb.org/draft/security.html

http://packages.python.org/CouchDB/client.html

http://code.google.com/p/couchdb-python/

http://wiki.apache.org/couchdb/Getting_ ... ith_Python

http://wiki.python.org/moin/SQLite

http://www.devshed.com/c/a/Python/Using ... in-Python/

http://www.couchbase.com/

https://cloudant.com/

4. Measure 10 times and saw one.

The top of laziness is to do everything correct from the beginning. Think ahead. Think 5 - 10 years into the future. Ask yourself. What do I need? Is a key value combination that can be loaded into json http://docs.python.org/library/json.html structure all I need? Is security important? Do I need a database that can be run on the same server as your site? Or do I need one or more stand alone data base servers? Do I even need multiple data senters. The solution you choose is very important, so if you can not answer the above questions alone, contact a database expert that don't shoot sparrows with canons.

Example: If you need to run a big board http://www.big-boards.com/ you may soon run into problems if you don't know the bottlenecks. But for text mining, like it is described in this http://shop.oreilly.com/product/0636920010203.do book a simple Python / Redis / CouchDB solution may be good enough. Sometimes good enough is best. And SQLite comes with Python and is implemented in your file system. It is minimalistic and easy to use on a your laptop that you can carry with you on a holiday.

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest