[Tutor] Method to create small and simple database

Joel Montes de Oca joelmontes01 at gmail.com
Sat Oct 29 20:28:39 CEST 2011


On Sat Oct 29 14:14:24 2011, Joel Montes de Oca wrote:

>
> On Sat Oct 29 13:29:59 2011, Peter Otten wrote:
>>
>> Joel Montes de Oca wrote:
>>
>>>
>>> Hello everyone,
>>>
>>> About me:
>>>
>>> This is the first time I post to Tutor at Python.org.
>>>
>>> I am brand spanking new to Python. I can create simple application,
>>> gone
>>> through a few tutorials and watched the Google Python 2 day class on
>>> Youtube. (List of classes: http://goo.gl/Ud5rg)
>>>
>>> Just yesterday I figured out how to load up a GUI made in Glade and
>>> pass
>>> singles around and what not. Huge accomplishment for me since
>>> documentation is a bit shaky for noobs like me. :)
>>>
>>> I have some programming knowledge. I learned (self tough) VB when I was
>>> in middle school and then did a intro to C++ in college. Of course
>>> mentioning that is trivial since I haven't done any programming for
>>> about 5 years or so.. But I do know basic concepts. Just need a little
>>> push in the right direction..
>>>
>>> --------------------------------------
>>>
>>> I think I know how to design my application but I would like to put it
>>> on here for you guys to review and provide me with feedback/suggestions
>>> as to the best way to go about it.
>>>
>>> --------------------------------------
>>>
>>> The application:
>>>
>>> I want to build a simple application that keeps track of items
>>> borrowers
>>> check out. So the end user types in the names of /borrowers/ and also
>>> types in a list of /items/. Then the end user checks out the /items/ to
>>> the /borrowers/.
>>>
>>> The category that my application would fall under is close to
>>> /collection management tools/. Here's a list of a few other
>>> applications
>>> that do something like what I am aiming for:
>>> http://www.makeuseof.com/tag/4-open-source-collection-manager-apps/
>>>
>>> In addition to the application keeping track of who has what, I would
>>> like to code the date the items are out, which borrowers have not
>>> borrowed anything in the last month, and so on. That said, I need to
>>> setup some kind of database like file. I don't want to have a database
>>> server though.
>>>
>>> The reason I want to build a new tool is because:
>>>
>>> A) I want to play around with Python
>>> B) My friend needs the application to be simple and geared to his
>>> needs without too many extra bells& whistles
>>>
>>>
>>> --------------------------------------
>>>
>>>
>>> My method:
>>>
>>> I was thinking of using the lxmal module to construct a XML file to
>>> read/write all the information.
>>>
>>> I figured this was the easiest way to do what I need since the
>>> information is setup as a tree. (Easy to think about and see) Example:
>>>
>>> <app>
>>> <borrowers>
>>>
>>> <user>John Doe</user>
>>>
>>> <checked out> Item1:Item2:||2011/4/2</checked out>
>>>
>>> <user>Mary Doe</user>
>>>
>>> <checked out> Item3||2011/7/22</checked out>
>>>
>>> </borrowers>
>>> <objects>
>>>
>>> <item>Item1</item>
>>>
>>> <createdOn>2011/2/1</createdOn>
>>>
>>> <checked_out_times>32</checked_out_times>
>>>
>>> <item>Item2</item>
>>>
>>> <createdOn>2011/2/1</createdOn>
>>>
>>> <checked_out_times>22</checked_out_times>
>>>
>>> <item>Item3</item>
>>>
>>> <createdOn>2011/2/1</createdOn>
>>>
>>> <checked_out_times>1</checked_out_times>
>>> </objects>
>>> </app>
>>>
>>> The application will not be used in an enterprise kind of environment.
>>> The application is meant to hold about 80 borrowers and about 100 items
>>> and that's about it.
>>>
>>> Is this a good way to go about my project? Is there a better& easier
>>> way?
>>>
>>> I don't want to trade off "better" with "easy". Someone once suggested
>>> on Freenode #Python that I should use a sql database. I don't remember
>>> the name of it. It was something like lightsql or something like that.
>>> That particular database didn't use a server end. I guess it spit out a
>>> txt database or something... This might be a good time to mention I
>>> know
>>> very little about database construction or sql commands.
>>>
>>> Anyhow, I am looking forward to hearing opinion's and suggestions.
>>
>>
>> Well, using sqlite
>>
>> http://docs.python.org/library/sqlite3.html
>>
>> may be both better and easier than lxml, but for the tiny amount of
>> data you
>> are planning to handle you can also make do with a few of Python's
>> lists and
>> dicts, and use pickle
>>
>> http://docs.python.org/library/pickle.html
>>
>> to save the data when you're done. It won't get easier than that.
>>
>> _______________________________________________
>> Tutor maillist - Tutor at python.org
>> To unsubscribe or change subscription options:
>> http://mail.python.org/mailman/listinfo/tutor
>
>
>
> Awesome Peter,
>
> Yea, sqlite3 was what the good folks on irc.freenode.net #Python told
> me to use but the pickle module seems like the simpliest way to get
> the job done.
>
> I'll look into both of them. I'm going to have to rethink how I am
> going to build the program using sqlite or pickle().
>
> Thanks again
>
> -Joel M.


After looking at the Python module documentation for sqlite3 
(http://docs.python.org/library/sqlite3.html#module-sqlite3), it seems 
to me it's the best way to make the small database that I am looking for.

Now I need to look for a basic tutorial on constructing a simple 
database (tables, rows, keys) and how to connect all that stuff 
together. If anyone happens to know of a good intro tutorial or 
documentation to database concepts, please forward it to me.

Thanks!



More information about the Tutor mailing list