[Tutor] File vs. Database (possible off topic)

Modulok modulok at gmail.com
Tue Nov 22 04:14:57 CET 2011


On 11/21/11, Ken G. <beachkidken at gmail.com> wrote:
> It occurred to me last week while reviewing the files I made in using
> Python, it could be somewhat similar to a database.
>
> What would be a different between a Python files and Python databases?
> Granted, the access in creating them are different, I really don't see
> any different in the format of a file and a database.
>
> Again, this may be off topic, but where can I review the basic concepts
> of creating a database/file.  For example, when is a back up file
> created, after inputting a new value?  Is sorting a consider a separate
> program after inputting a new value?  It has been some 30 years since I
> took a course in basic data processing and I am hazy in trying to
> remember the basic concepts.
>
> If this is off topic, I apologized for posting here.
>
> Ken, Kentucky, USA

Generally speaking,

If you ever even think the word 'database', your best choice 98% of the time is
sqlite. (The module is called 'sqlite3' in python.) Reading up on SQL on
wikipedia and sqlite3 in the python docs is a good place to start!

Eventually, if you start storing a massive number of records and need things
like concurrent access and load balancing across multiple physical machines and
so forth, sqlite isn't going to cut the mustard. In such cases people use a
dedicated database server like postgresql, mysql, etc; A totally separate
program that does nothing but database black magic. Your python programs will
talk to the database server through a module written for that server. The
database server will fetch, sort, update and store the actual data.

Python has bindings to these heavy weight database backends through third party
modules that abstract the details for you. The most popular module is probably
sqlalchemy. It talks to postgresql, mysql and a few others. It's a good idea to
get used to sqlite and general SQL concepts before you jump into sqlalchemy!

Good luck!
-Modulok-


More information about the Tutor mailing list