Re: simple client data base
Mark R Rivet wrote: Thomas 'PointedEars' Lahn wrote: Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. […] However, if you want your program to manipulate the data *persistently*. as it will probably be needed for business, you will need to also store it somewhere else than in the volatile memory in which these data structures are usually stored. The most simple way would be to store and parse the string representation of the objects. Production-quality implementations of those and other concepts already exist, of course, but using something finished and polished does not provide as much learning experience. Now this is the kind of answer I was hoping for. This gives me food for thought. Now I have some Ideas of how to appproach this thing. I know that there are solutions to this problem already but I need to do my own before I can really use anything better. Thanks for the help. I fully intend to go with a real realational database, but not now. My version 1 will be a console interface and dictionaries, lists and pickling. Version 2 will be with a GUI written in tkinter, and better and better. I just want to learn how to lay the bricks before I start using prefab walls. You are welcome. However, I have to concur with the others that in terms of efficiency and reliability, which leads to household peace, you are better off starting with a prepackaged solution instead. You can keep developing your Python-powered database as a pet project for the time being. Your wife will be even more impressed if at one day you can tell her that you wrote completely customizable software that works the same or even better than the one she has been getting used to :) Even if not, you will have learned much about Python and related concepts along the way. Keep in mind, then, that you probably also need a graphical user interface. Please trim your quotes to the relevant minimum next time. -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Mark R Rivet wrote: Well I have to say that this is most discouraging. Sorry to to be a drag, but the thread needed a bit a realism. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On 09/08/12 14:47, Mark R Rivet wrote: Well I have to say that this is most discouraging. I should give up learning to program. I don't have a chance at all. Thanks. I think the intent is not to deter you from learning to program, but rather to urge you in a direction less fraught with peril. Rather than starting by duplicating existing functionality of a complex domain, you may find it easier to start by aiming for something in a less-complex domain, or tackle a project that doesn't already exist but scratches your personal itch. As you succeed at smaller projects, you'll have a better idea of how to tackle larger projects in the future. -tkc -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Tim Chase python.l...@tim.thechases.com writes: urge you in a direction less fraught with peril. Rather than starting by duplicating existing functionality of a complex domain More importantly, as others have mentioned, the main peril comes from having someone else relying on the success of the program. If you want to learn to play the violin, that's great. Just don't book a recital in Carnegie Hall until you've practiced for a while in private to get your skills in order. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Mon, 03 Sep 2012 16:50:14 +0200, Peter Otten __pete...@web.de wrote: Chris Angelico wrote: You may also be needlessly reinventing the wheel. Aren't there already several million basic contact databases around? Why roll your own? To learn a thing or two, and to stick it to the defeatists ;) Yes, that's the reason. I need to learn something. Without getting into the complexities of relational database's for now. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Wed, 5 Sep 2012 05:57:24 -0700 (PDT), Ramchandra Apte maniandra...@gmail.com wrote: On Monday, 3 September 2012 19:42:21 UTC+5:30, Manatee wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. If there are not more than 1000 records you can just use `pickle` Yes, not more than a 1000. My wifes clients only number 300. So not much of a problem for now I guess. I can't see it growing to double that, because 300 clients takes alot of work as it is. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Tue, 04 Sep 2012 04:25:14 +0200, Thomas 'PointedEars' Lahn pointede...@web.de wrote: Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. The data types that would choose are defined by your requirements and how well a data type meets your requirements. I can imagine: In a database you would want quick access to data. You would want to access fields primarily by name. You would also want to filter data by various criteria. Therefore, it appears to me that it would be best if your records were dictionaries or dictionary-like objects, and your recordsets were lists of records, like so #!/usr/bin/env python3 from datetime import date data = [ { 'lastname': 'Doe', 'firstname': 'John', 'sn':'123-451-671-890', 'birthdata': date(2000, 1, 2) }, { 'lastname': 'Doe', 'firstname': 'Jane', 'sn':'409-212-582-452', 'birthdata': date(2001, 2, 3) }, ] - You could quickly access the second record with data[1]. - You could access the 'lastname' field of the second record with data[1]['lastname'] - You could get a list of records where the person is born before 2001 CE with filter(lambda record: record['birthdate'] date(2001, 1, 1), data) The advantage of dictionaries over dictionary-like objects is that they are easily extensible and that the memory footprint is probably lower (CMIIW); the disadvantage is slightly more complicated syntax and that you have to keep track of the keys. Therefore, you might want to consider instantiating a Record class instead; in its simplest form: class Record(object): def __init__(self, lastname, firstname, sn=None, birthdate=None): self.lastname = lastname self.firstname = firstname self.sn = str(sn) self.birthdate = birthdate data = [ Record(lastname='Doe', firstname='John', sn='123-451-671-890', birthdate=date(2000, 1, 2)), Record(lastname='Doe', firstname='Jane', sn='409-212-582-452', birthdate=date(2001, 2, 3)) ] - You could access the 'lastname' property of the second record with data[1].lastname - You get a list of records where the person is born before 2001 CE with list(filter(lambda record: record.birthdate date(2001, 1, 1), data)) (in Python 2.x without list()) However, if you want your program to manipulate the data *persistently*. as it will probably be needed for business, you will need to also store it somewhere else than in the volatile memory in which these data structures are usually stored. The most simple way would be to store and parse the string representation of the objects. Production-quality implementations of those and other concepts already exist, of course, but using something finished and polished does not provide as much learning experience. HTH Now this is the kind of answer I was hoping for. This gives me food for thought. Now I have some Ideas of how to appproach this thing. I know that there are solutions to this problem already but I need to do my own before I can really use anything better. Thanks for the help. I fully intend to go with a real realational database, but not now. My version 1 will be a console interface and dictionaries, lists and pickling. Version 2 will be with a GUI written in tkinter, and better and better. I just want to learn how to lay the bricks before I start using prefab walls. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Thu, 6 Sep 2012 01:57:04 -0700 (PDT), Bryan bryanjugglercryptograp...@yahoo.com wrote: Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. Among programming languages Python is exceptionally easy to learn, and rocks for the kind of app you describe, but your goal is not realistic. Simple is better than complex, but what you can build at this point is far from what a professional accountant with her own business needs from a client database manager. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. Those are good classes to read about, and I dare say that most Pythoneers at some time faced confusion as to which were most appropriate for the problem at hand. You'd need of all them and more, a whole freak'in bunch more, to build a professional quality contact manager app. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. comp.lang.python tries to be friendly and helpful, and to that end responders have read and answered your question as directly as possible. There's good stuff available for Python. Mark, there is absolutely no chance, no how, no way, that your stated plan is a good idea. Fine CRM apps are available for free; excellent ones for a few dollars. You're reading about lists, tuples, and dictionary data? Great, but other home accounting businesses have their client databases automatically synced with their smart-phones and their time-charging and their invoicing. -Bryan Well I have to say that this is most discouraging. I should give up learning to program. I don't have a chance at all. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. Among programming languages Python is exceptionally easy to learn, and rocks for the kind of app you describe, but your goal is not realistic. Simple is better than complex, but what you can build at this point is far from what a professional accountant with her own business needs from a client database manager. I am married, and I wonder what his wife will think if she discovers that she could have had her solution yesterday. My wife would not tolerate the roll-your-own approach, but every marriage is different. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Mark R Rivet markrri...@aol.com writes: ones for a few dollars. You're reading about lists, tuples, and dictionary data? Great, but other home accounting businesses have their client databases automatically synced with their smart-phones and their time-charging and their invoicing. Well I have to say that this is most discouraging. I should give up learning to program. I don't have a chance at all. Thanks. I think the idea is just to start with something simpler. If you are interested in mechanical engineering, then building an automobile from scratch, machining all the parts yourself etc., would be an ill-advised choice as a first project. It's the same way with programming. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Sat, Sep 8, 2012 at 3:11 PM, Paul Rubin no.email@nospam.invalid wrote: I think the idea is just to start with something simpler. If you are interested in mechanical engineering, then building an automobile from scratch, machining all the parts yourself etc., would be an ill-advised choice as a first project. It's the same way with programming. I'm wondering what his backup plan is for the information, in case his database somehow messes things up. It's smarter to start with something that's not vital to the functioning of your wife's business. Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Sat, 08 Sep 2012 13:11:27 -0700, Paul Rubin wrote: Mark R Rivet markrri...@aol.com writes: ones for a few dollars. You're reading about lists, tuples, and dictionary data? Great, but other home accounting businesses have their client databases automatically synced with their smart-phones and their time-charging and their invoicing. Well I have to say that this is most discouraging. I should give up learning to program. I don't have a chance at all. Thanks. I think the idea is just to start with something simpler. If you are interested in mechanical engineering, then building an automobile from scratch, machining all the parts yourself etc., would be an ill-advised choice as a first project. It's the same way with programming. And he has it backwards anyway, IMHO. If he wants a client database and insists on building it himself, he should start with the relational database and work up; not from the GUI and try to work down with silly solutions like pickling. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Sat, 2012-09-08, Mark R Rivet wrote: On Thu, 6 Sep 2012 01:57:04 -0700 (PDT), Bryan bryanjugglercryptograp...@yahoo.com wrote: ... comp.lang.python tries to be friendly and helpful, and to that end responders have read and answered your question as directly as possible. There's good stuff available for Python. Mark, there is absolutely no chance, no how, no way, that your stated plan is a good idea. Fine CRM apps are available for free; excellent ones for a few dollars. You're reading about lists, tuples, and dictionary data? Great, but other home accounting businesses have their client databases automatically synced with their smart-phones and their time-charging and their invoicing. -Bryan Well I have to say that this is most discouraging. I should give up learning to program. I don't have a chance at all. Thanks. He's saying you don't have a chance, but he's *not* telling you to give up programming. Personal reflection: it's risky to make friends and relatives depend on the success of your hobby projects. I got away with it once or twice (under special circumstances) but it might equally well have ended with resentment. Why did he sell this crap idea to me? Now I'm stuck with it. /Jorgen -- // Jorgen Grahn grahn@ Oo o. . . \X/ snipabacken.se O o . -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. Among programming languages Python is exceptionally easy to learn, and rocks for the kind of app you describe, but your goal is not realistic. Simple is better than complex, but what you can build at this point is far from what a professional accountant with her own business needs from a client database manager. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. Those are good classes to read about, and I dare say that most Pythoneers at some time faced confusion as to which were most appropriate for the problem at hand. You'd need of all them and more, a whole freak'in bunch more, to build a professional quality contact manager app. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. comp.lang.python tries to be friendly and helpful, and to that end responders have read and answered your question as directly as possible. There's good stuff available for Python. Mark, there is absolutely no chance, no how, no way, that your stated plan is a good idea. Fine CRM apps are available for free; excellent ones for a few dollars. You're reading about lists, tuples, and dictionary data? Great, but other home accounting businesses have their client databases automatically synced with their smart-phones and their time-charging and their invoicing. -Bryan -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Monday, 3 September 2012 19:42:21 UTC+5:30, Manatee wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. If there are not more than 1000 records you can just use `pickle` -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Personally, I wouldn't bother with SQLAlchemy for this. I'd just use Python as the front end, PostgreSQL for the database, and psycopg2 for the interface. Then you have to implement the entire logic, event binding etc. yourself. If you use e.g. Pypapi (the latest version), implementing an entire CRUD application is as simple as declaring your domain object model and laying out your GUI with Qt Designer. In Sqlkit, you don't have to do much more, you just don't use a designer for the GUI, but also a declarative approach. Sincerely, Wolfgang -- http://mail.python.org/mailman/listinfo/python-list
simple client data base
Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list
simple client data base
Hi, You can try gadfly ! This system is based on SQL. Loïc From: markrri...@aol.com Subject: simple client data base Date: Mon, 3 Sep 2012 10:12:11 -0400 To: python-list@python.org Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Tue, Sep 4, 2012 at 12:12 AM, Mark R Rivet markrri...@aol.com wrote: I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I think you're looking at this backwards. A database is for storing information on disk, but lists/tuples/dicts are for manipulating it in memory. You may also be needlessly reinventing the wheel. Aren't there already several million basic contact databases around? Why roll your own? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Hi, You can make use of sqlite database also. And for the structure, you can create a single table and different columns for the fields like name, number etc. You can get more details over here. http://docs.python.org/library/sqlite3.html Thanks, Anoop Thomas Mathew atm ___ Life is short, Live it hard. On 3 September 2012 19:51, loïc Lauréote laureote-l...@hotmail.fr wrote: Hi, You can try gadfly ! This system is based on SQL. Loïc * *** From: markrri...@aol.com Subject: simple client data base Date: Mon, 3 Sep 2012 10:12:11 -0400 To: python-list@python.org Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Monday, 3 September 2012 15:12:21 UTC+1, Manatee wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. How about the half-way house, sqlite3 which comes with python? hth -- mph -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On 03/09/2012 15:12, Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. Thanks for your help. If you stick with the simple data structures at some point you're going to have to save them to disk with a module like pickle or shelve. IMHO using sqlite is a better option as it comes with Python. -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Chris Angelico wrote: You may also be needlessly reinventing the wheel. Aren't there already several million basic contact databases around? Why roll your own? To learn a thing or two, and to stick it to the defeatists ;) -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On 3 September 2012 15:12, Mark R Rivet markrri...@aol.com wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I would use the sqlite3 module for this (if I wasn't using gmail contacts). I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. As already said by Chris these are the types that Python uses to represent data in memory, rather than on disk. There are a number of ways that you can use these to represent the information from your database. For example, you could use a dict of dicts: contact_db = {} # empty dict contact_db['john'] = {'alias':'john', 'name':'John Doe', 'email': ' j...@example.com'} contact_db['dave'] = {'alias':'dave', 'name':'Dave Doe', 'email': ' d...@example.com'} contact_db {'dave': {'alias': 'dave', 'name': 'Dave Doe', 'email': 'd...@example.com'}, 'john': {'alias': 'john', 'name': 'John Doe', 'email': 'j...@example.com'}} contact_db['dave'] {'alias': 'dave', 'name': 'Dave Doe', 'email': 'd...@example.com'} contact_db['dave']['email'] 'd...@example.com' I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. If you don't want to use real database capabilities you could save the data above into a csv file using the csv module: import csv with open('contacts.csv', 'wb') as f: ... writer = csv.DictWriter(f) ... writer.writelines(contact_db.values()) You can then reload the data with: with open('contacts.csv', 'rb') as f: ... reader = csv.DictReader(f, ['alias', 'name', 'email']) ... new_contact_db = {} ... for row in reader: ... new_contact_db[row['alias']] = row ... new_contact_db {'dave': {'alias': 'dave', 'name': 'Dave Doe', 'email': 'd...@example.com'}, 'john': {'alias': 'john', 'name': 'John Doe', 'email': 'j...@example.com'}} contact_db == new_contact_db True Can anyone give me some idea's or tell me which structure would be best to use? The above method for storing the data on disk is simple but not very safe. If you use it for your wife's business make sure that you are always keeping backups of the file. Preferably don't overwrite the file directly but write the data out to a separate file first and then rename the file (to avoid loss of data if the program has an error while writing). The obvious way to improve on the above is to use the sqlite3 module to store the data in an sqlite3 file instead of a csv file. There is one advantage to using the above over using an sqlite3 database which is that the data can be edited manually as a text file or using standard spreadsheet software if necessary. Oscar -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. hint Python imho would be in need of a really good accounting application as a demonstrator for its capabilities. ;-) /hint I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. The list of Python frameworks for rapid development of desktop (i.e. non-Web) database applications currently contains: using PyQt ( Sqlalchemy): Pypapi: www.pypapi.org Camelot: www.python-camelot.com Qtalchemy: www.qtalchemy.org using PyGTK: Sqlkit: sqlkit.argolinux.org (also uses Sqlalchemy) Kiwi: www.async.com.br/projects/kiwi using wxPython: Dabo: www.dabodev.com Defis: sourceforge.net/projects/defis (Russian only) GNUe: www.gnuenterprise.org Pypapi, Camelot, Sqlkit and Dabo seem to be the most active and best documented/supported ones. Sqlalchemy (www.sqlalchemy.org) seems to be quite useful for working with databases. Those of the above mentioned frameworks that don't use it do so for historic reasons, because the corresponding project started before Sqlalchemy became known. If you want to rely on not losing your data, you might want to use PostgreSQL (www.postgresql.org) as a storage backend with any of these. Sincerely, Wolfgang P.S.: If anyone knows of frameworks not listed here, thanks for mailing me. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
On Mon, 03 Sep 2012 18:03:27 +0200, Wolfgang Keller wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. hint Python imho would be in need of a really good accounting application as a demonstrator for its capabilities. ;-) /hint I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. The list of Python frameworks for rapid development of desktop (i.e. non-Web) database applications currently contains: using PyQt ( Sqlalchemy): Pypapi: www.pypapi.org Camelot: www.python-camelot.com Qtalchemy: www.qtalchemy.org using PyGTK: Sqlkit: sqlkit.argolinux.org (also uses Sqlalchemy) Kiwi: www.async.com.br/projects/kiwi using wxPython: Dabo: www.dabodev.com Defis: sourceforge.net/projects/defis (Russian only) GNUe: www.gnuenterprise.org Pypapi, Camelot, Sqlkit and Dabo seem to be the most active and best documented/supported ones. Sqlalchemy (www.sqlalchemy.org) seems to be quite useful for working with databases. Those of the above mentioned frameworks that don't use it do so for historic reasons, because the corresponding project started before Sqlalchemy became known. If you want to rely on not losing your data, you might want to use PostgreSQL (www.postgresql.org) as a storage backend with any of these. Personally, I wouldn't bother with SQLAlchemy for this. I'd just use Python as the front end, PostgreSQL for the database, and psycopg2 for the interface. -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
If you're just starting to learn python/computer science, why not try setting up section fields in a file that you can parse, with your own database. Then you can parse through, append, delete, etc and this will show you the 'higher' level of db's. Plus, I don't think anyone has mentioned RDBM: http://en.wikipedia.org/wiki/Relational_database_management_system or these from python: www.python.org/dev/peps/pep-0249/ http://wiki.python.org/moin/DatabaseProgramming/ -- Best Regards, David Hutto *CEO:* *http://www.hitwebdevelopment.com* -- http://mail.python.org/mailman/listinfo/python-list
Re: simple client data base
Mark R Rivet wrote: Hello all, I am learning to program in python. I have a need to make a program that can store, retrieve, add, and delete client data such as name, address, social, telephone number and similar information. This would be a small client database for my wife who has a home accounting business. I have been reading about lists, tuples, and dictionary data structures in python and I am confused as to which would be more appropriate for a simple database. I know that python has real database capabilities but I'm not there yet and would like to proceed with as simple a structure as possible. Can anyone give me some idea's or tell me which structure would be best to use? Maybe its a combination of structures? I need some help. The data types that would choose are defined by your requirements and how well a data type meets your requirements. I can imagine: In a database you would want quick access to data. You would want to access fields primarily by name. You would also want to filter data by various criteria. Therefore, it appears to me that it would be best if your records were dictionaries or dictionary-like objects, and your recordsets were lists of records, like so #!/usr/bin/env python3 from datetime import date data = [ { 'lastname': 'Doe', 'firstname': 'John', 'sn':'123-451-671-890', 'birthdata': date(2000, 1, 2) }, { 'lastname': 'Doe', 'firstname': 'Jane', 'sn':'409-212-582-452', 'birthdata': date(2001, 2, 3) }, ] - You could quickly access the second record with data[1]. - You could access the 'lastname' field of the second record with data[1]['lastname'] - You could get a list of records where the person is born before 2001 CE with filter(lambda record: record['birthdate'] date(2001, 1, 1), data) The advantage of dictionaries over dictionary-like objects is that they are easily extensible and that the memory footprint is probably lower (CMIIW); the disadvantage is slightly more complicated syntax and that you have to keep track of the keys. Therefore, you might want to consider instantiating a Record class instead; in its simplest form: class Record(object): def __init__(self, lastname, firstname, sn=None, birthdate=None): self.lastname = lastname self.firstname = firstname self.sn = str(sn) self.birthdate = birthdate data = [ Record(lastname='Doe', firstname='John', sn='123-451-671-890', birthdate=date(2000, 1, 2)), Record(lastname='Doe', firstname='Jane', sn='409-212-582-452', birthdate=date(2001, 2, 3)) ] - You could access the 'lastname' property of the second record with data[1].lastname - You get a list of records where the person is born before 2001 CE with list(filter(lambda record: record.birthdate date(2001, 1, 1), data)) (in Python 2.x without list()) However, if you want your program to manipulate the data *persistently*. as it will probably be needed for business, you will need to also store it somewhere else than in the volatile memory in which these data structures are usually stored. The most simple way would be to store and parse the string representation of the objects. Production-quality implementations of those and other concepts already exist, of course, but using something finished and polished does not provide as much learning experience. HTH -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail. -- http://mail.python.org/mailman/listinfo/python-list