"Ken G." <beach...@insightbb.com> wrote: > I have not use the DBMS as I am unaware of them in both languages.
DBMS is short for Data Base Management System, see wikipedia entry on the topic. Actually, the term is a bit ambiguous: * From a user point of view, a BDMS will be an application allowing managing data sets in a hopefully meaningful and easy manner. * From a programmer point of view, it will be a system for wich a binding exists in one's favorite programming language, meaning a library that that can be imported. > Lie Ryan wrote: > > Ken G. wrote: > >> The way I use to do it in another programming language (Liberty Basic > >> in Windows) was: > >> > >> 1. Count number of data entry in database. > >> 2. Dimension or create an array to equal the maximum number of entry. > >> 3. Copy data entry from database into array. > >> 4. Use the SORT command on array, ascending or descending sequence. > >> 5. Copy sorted data from array into database. > > > > In any programming language, that was the wrong algorithm, except for > > very low-volume purpose. You should ask the DBMS system to sort the > > database whenever possible instead of doing the sorting yourself. > > > >> From what I know of Python so far, is it possible to sort the > >> database as it or do I have to copy data into either a list, tuple or > >> dictionary and sort there and then, after sorting copy sorted entry > >> back into the database. > > > > Question time: > > 1. What DBMS are you using? > > 2. What python interface to the DBMS you are using? > > 3. Why do you think you need to sort the database? There is no > > advantage (that I know of) of having a sorted database. A decent DBMS > > should determine how best to store the data (it's their problem, not > > yours). If your DBMS can't do this, you should consider using another > > DBMS. > > 4. Can't you simply sort the queried data? An SQL-based DBMS should > > support ORDER BY command to sort the SELECT-ed rows. That should be > > faster than sorting the whole database. You can sort the returned > > tuple yourself, but it would be very difficult to beat the DBMS's > > ORDER BY. > > > >> An outline of what needed to be done will be fine so I can study and > >> learn the proper way of doing this in Python. FWIW, I just finished > >> Alan's tutorial on list, tuple and dictionary. Whew!!! Quite > >> comprehensive. > > As stated, I am unaware of any DBMS in both languages. In Basic and > > now in Python, I wrote up a program to input data to the datafile and > > a program to output the content of the database. Very primitive and > > basic. > > All of the databases I spoke of are arranged by date and if necessary, > time. One contains my blood glucose reading and it is now, the newest > entry is at the bottom of the database. I need to arrange it in > descending order whereas I can print out a report of the last 55 entries > for my doctor. Some of the entries in the other databases are not in > sequenced order and I wish them to be, either ascending or descending > sequence. The data are numerical, ranging in the length of 20, 22 and > 44 long with no spaces. I'm not sure of what order is in the file, and what order you want. Seems the data is ordered by date/time, so maybe you would like to sort last n entries by glucose rate? but it's not such clear for me. What is clear: * The data files are "hand-made" data recordings. * You don't need a complicated (relational) DBMS. If you have a bit of free time, I would advise to explore both: * Sorting the data from files as are now (you will need to sort "records" on the proper column). * Using the simplest possible DBMS available from python, namely I guess SQLite (correct me if I'm wrong), to replace your data storing system. > Thank you for letting me look a little further into DBMS. > > Ken ________________________________ la vita e estrany http://spir.wikidot.com/ _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor