I have not use the DBMS as I am unaware of them in both languages.
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.
Thank you for letting me look a little further into DBMS.
Ken
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor