473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

How to store data?

Hi there!

For a web project I need a little expert help. I don't have written much
code yet, just been fiddling around a bit, testing and planning.

The web site will have a submission page for attendants of a congress.
In a form the user will submit name, mailadress etc. and I plan to store
the data in a list of dictionaries:

People = [{'name' : 'Sir Galahad', 'address' : 'Camelot', 'mail' :
'C************@england.com'}]

#new attendant:
People.append({'name' : 'Brian', 'address' : 'Palestine', 'mail' :
'f******************@rome.com'})

The 'lines' can be accessed by their index.

Now my question: Where do you suggest to store the data? I know that
something sql-like would be quite useful but I don't have any knowledge
of sql. So I thought about putting the data either into a comma
separated file or pickling it.

I should mention that some other people on different operation systems
should be able to import the file (Excel, Open Office) so I tend towards
the csv file.

What would be better?

And another problem: How to lock the file when several users try to
write to it?

As I'm no very experienced programmer I would appreciate your help,
thanks in advance

Cheerz Lars




Jul 18 '05 #1
5 3375

"Lars Behrens" <Sp*********@web.de> wrote in message
news:bi************@ID-95936.news.uni-berlin.de...
Hi there!

For a web project I need a little expert help. I don't have written much
code yet, just been fiddling around a bit, testing and planning.

The web site will have a submission page for attendants of a congress.
In a form the user will submit name, mailadress etc. and I plan to store
the data in a list of dictionaries:

People = [{'name' : 'Sir Galahad', 'address' : 'Camelot', 'mail' :
'C************@england.com'}]

#new attendant:
People.append({'name' : 'Brian', 'address' : 'Palestine', 'mail' :
'f******************@rome.com'})

The 'lines' can be accessed by their index.

Now my question: Where do you suggest to store the data? I know that
something sql-like would be quite useful but I don't have any knowledge
of sql. So I thought about putting the data either into a comma
separated file or pickling it.

I should mention that some other people on different operation systems
should be able to import the file (Excel, Open Office) so I tend towards
the csv file.

What would be better?
Python 2.3 has an excellent CSV module.
And another problem: How to lock the file when several users try to
write to it?

As I'm no very experienced programmer I would appreciate your help,
thanks in advance
John Roth
Cheerz Lars



Jul 18 '05 #2

"Lars Behrens" <Sp*********@web.de> wrote in message
news:bi************@ID-95936.news.uni-berlin.de...
Hi there!

For a web project I need a little expert help. I don't have written much
code yet, just been fiddling around a bit, testing and planning.

The web site will have a submission page for attendants of a congress.
In a form the user will submit name, mailadress etc. and I plan to store
the data in a list of dictionaries:

People = [{'name' : 'Sir Galahad', 'address' : 'Camelot', 'mail' :
'C************@england.com'}]

#new attendant:
People.append({'name' : 'Brian', 'address' : 'Palestine', 'mail' :
'f******************@rome.com'})

The 'lines' can be accessed by their index.

Now my question: Where do you suggest to store the data? I know that
something sql-like would be quite useful but I don't have any knowledge
of sql. So I thought about putting the data either into a comma
separated file or pickling it.

I should mention that some other people on different operation systems
should be able to import the file (Excel, Open Office) so I tend towards
the csv file.

What would be better?
Python 2.3 has an excellent CSV module.
And another problem: How to lock the file when several users try to
write to it?

As I'm no very experienced programmer I would appreciate your help,
thanks in advance
John Roth
Cheerz Lars



Jul 18 '05 #3
Lars-

I don't want to see you cut on bleeding edge software, but, I just
released an updated version of the Pointrel Data Repository System
http://sourceforge.net/projects/pointrel/
which could in theory handle such a task (subject to bugs etc.), and I
could not resist responding to your post. The Pointrel System can handle
simple locking and simple transactions (although this has only be tested
recently under GNU/Linux and Python2.3). As a caveat, this Pointrel
System database bunny may have long pointy, nasty teeth, etc., and so if
your application is mission critical you should most likely go with a
more proven solution -- like a convetional relational database (and
using SQL to access one is a good skill to learn). And possibly if your
needs are minimal, pickling your dictionaries or using the 'shelve'
module might just be good enough for a simple application.

Mainly just for fun, and also as another example for people who are
interested in playing with the related concepts, rather than to try to
persuade you specifically to try the Pointrel System (since if you are
not an experienced programmer you would have no way to judge what you
were getting into, and so my best advice to you specifically would be to
go with something proven like pickle, shelve, SQL etc.), here is how you
might solve the storage issue you outline using the Pointrel System:

==================================================
File: "congress.py"
==================================================

from pointrel20030812 import *

Pointrel_initialize("archive_congress")

# add a first attendant -- uses built in unique ID function
# but could be any unique ID string
# each change will be implicitely a seperate transaction
attendantID = Pointrel_generateUniqueID()
Pointrel_add("congress", attendantID, 'object type', 'user')
Pointrel_add("congress", attendantID, 'name', 'Sir Galahad')
Pointrel_add("congress", attendantID, 'address', 'Camelot')
Pointrel_add("congress", attendantID, 'mail', 'C************@england.com')

# add a second attendant, this time as an atomic transaction
attendantID = Pointrel_generateUniqueID()
Pointrel_startTransaction()
Pointrel_add("congress", attendantID, 'object type', 'user')
Pointrel_add("congress", attendantID, 'name', 'Brian')
Pointrel_add("congress", attendantID, 'address', 'Palestine')
Pointrel_add("congress", attendantID, 'mail',
'f******************@rome.com')
Pointrel_finishTransaction()

# add a third attendant, again as a single transaction
attendantID = Pointrel_generateUniqueID()
Pointrel_startTransaction()
Pointrel_add("congress", attendantID, 'object type', 'user')
Pointrel_add("congress", attendantID, 'name', 'Lars')
Pointrel_add("congress", attendantID, 'address', 'Pythonland')
Pointrel_add("congress", attendantID, 'mail', 'l***@example.com')
Pointrel_finishTransaction()

# update a value, as an implicit transaction
attendantID = Pointrel_lastMatch("congress", WILD, 'name', 'Sir Galahad')
Pointrel_add("congress", attendantID, 'address', "Zoot's castle")

# delete an attendant
attendantID = Pointrel_lastMatch("congress", WILD, 'name', 'Brian')
Pointrel_add("congress", attendantID, 'deleted', 'true')

# get a list of all attendants (deleted or not)
attendants = Pointrel_allMatches("congress", WILD, 'object type', 'user')
print '\nAll attendant IDs (including deleted ones):', attendants

# filter out deleted attendants
currentAttendants = filter(lambda user: Pointrel_lastMatch('congress',
user, 'deleted', WILD) <> 'true', attendants)
print '\nCurrent attendants:', currentAttendants

print "\nAttendant names:"
for attendant in currentAttendants:
print Pointrel_lastMatch('congress', attendant, 'name', WILD)

print "\nAttendant csv info"
for attendant in currentAttendants:
name = Pointrel_lastMatch('congress', attendant, 'name', WILD)
address = Pointrel_lastMatch('congress', attendant, 'address', WILD)
email = Pointrel_lastMatch('congress', attendant, 'mail', WILD)
print '"%s","%s","%s"' %(name, address, email)
# note proper csv output would require escaping embedded quotes etc.

==================================================
Sample output:
==================================================
creating archive file archive_congress.pointrel_database.poi
archive with only header

All attendant IDs (including deleted ones):
['unique://freevolution:23:43207645167115827',
'unique://freevolution:25:37062969616920138',
'unique://freevolution:26:11213192987278475']

Current attendants: ['unique://freevolution:23:43207645167115827',
'unique://freevolution:26:11213192987278475']

Attendant names:
Sir Galahad
Lars

Attendant csv info
"Sir Galahad","Zoot's castle","Ca***********@england.com"
"Lars","Pythonland","la**@example.com"

==================================================
Database file created: 'archive_congress.pointrel_database.xml'
(There is also a binary file which is maintained for efficiency).
==================================================

<?xml version="1.0" encoding="utf-8" ?>
<P:archive xmlns:P="http://www.pointrel.org/Pointrel20030812/NS/"
version="20030812.1" archiveID="unique://freevolution:24:35433055818285208">
<P:transaction>
<P:triad
r="1584L"
s="congress"
a="unique://freevolution:23:43207645167115827"
b="object type"
c="user"
/>
</P:transaction>
<P:transaction>
<P:triad
r="1984L"
s="congress"
a="unique://freevolution:23:43207645167115827"
b="name"
c="Sir Galahad"
/>
</P:transaction>
<P:transaction>
<P:triad
r="2376L"
s="congress"
a="unique://freevolution:23:43207645167115827"
b="address"
c="Camelot"
/>
</P:transaction>
<P:transaction>
<P:triad
r="2792L"
s="congress"
a="unique://freevolution:23:43207645167115827"
b="mail"
c="Ca***********@england.com"
/>
</P:transaction>
<P:transaction>
<P:triad
r="3104L"
s="congress"
a="unique://freevolution:25:37062969616920138"
b="object type"
c="user"
/>
<P:triad
r="3312L"
s="congress"
a="unique://freevolution:25:37062969616920138"
b="name"
c="Brian"
/>
<P:triad
r="3528L"
s="congress"
a="unique://freevolution:25:37062969616920138"
b="address"
c="Palestine"
/>
<P:triad
r="3760L"
s="congress"
a="unique://freevolution:25:37062969616920138"
b="mail"
c="fa*****************@rome.com"
/>
</P:transaction>
<P:transaction>
<P:triad
r="4072L"
s="congress"
a="unique://freevolution:26:11213192987278475"
b="object type"
c="user"
/>
<P:triad
r="4280L"
s="congress"
a="unique://freevolution:26:11213192987278475"
b="name"
c="Lars"
/>
<P:triad
r="4496L"
s="congress"
a="unique://freevolution:26:11213192987278475"
b="address"
c="Pythonland"
/>
<P:triad
r="4712L"
s="congress"
a="unique://freevolution:26:11213192987278475"
b="mail"
c="la**@example.com"
/>
</P:transaction>
<P:transaction>
<P:triad
r="4992L"
s="congress"
a="unique://freevolution:23:43207645167115827"
b="address"
c="Zoot's castle"
/>
</P:transaction>
<P:transaction>
<P:triad
r="5384L"
s="congress"
a="unique://freevolution:25:37062969616920138"
b="deleted"
c="true"
/>
</P:transaction>
</P:archive>

[And, as an example of bleeding edge, from testing this, I found a bug
from a last minute change I made to the unique ID system which had been
working well for a long time; it turns out that because of an error in
how I open a support file when it does not exists, the file
"a_pointrel_uniqueIDCounter.txt" now needs to exist in the local
directory with a number (e.g. '10') in it to get sequence numbers in
addition to a random ID component in unique IDs. The system still works
without this file though -- the unique IDs just aren't as collision
resistant. Something for an incremental release ASAP though.]

The one plug I'd put for the Pointrel System is that the simple (yet, I
hope, elegant) data storage approach is designed to be expandable with
changing needs over time, and usually data storage needs do change, and
in unexpected ways. Whether the Pointrel System can really deliver on
that promise remains to be seen. Again, MySql etc. have a proven track
record handling the sorts of issues you have outlined so far, and are
probably your best choice.

Anyway, if all this sounds like gibberish, feel free to ignore it! :-)

Best of luck with your project.

--Paul Fernhout

Lars Behrens wrote:
Hi there!

For a web project I need a little expert help. I don't have written much
code yet, just been fiddling around a bit, testing and planning.

The web site will have a submission page for attendants of a congress.
In a form the user will submit name, mailadress etc. and I plan to store
the data in a list of dictionaries:

People = [{'name' : 'Sir Galahad', 'address' : 'Camelot', 'mail' :
'C************@england.com'}]

#new attendant:
People.append({'name' : 'Brian', 'address' : 'Palestine', 'mail' :
'f******************@rome.com'})

The 'lines' can be accessed by their index.

Now my question: Where do you suggest to store the data? I know that
something sql-like would be quite useful but I don't have any knowledge
of sql. So I thought about putting the data either into a comma
separated file or pickling it.

I should mention that some other people on different operation systems
should be able to import the file (Excel, Open Office) so I tend towards
the csv file.

What would be better?

And another problem: How to lock the file when several users try to
write to it?

As I'm no very experienced programmer I would appreciate your help,
thanks in advance

Cheerz Lars


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
Jul 18 '05 #4
John Roth wrote:
Python 2.3 has an excellent CSV module.


Thx, I'll talk to my admin if upgrading would be possible.

Cheerz Lars

Jul 18 '05 #5

Thx for your help and hints and examples. But as you assume, my
application *is* mission critical. And as I read Pointres is only tested
under GNU/Linux but the server I have to use runs under Solaris, so I
have to find another solution.

Anyways, what I've read so far about Pointres sounds quite interesting
to me (especially because I'm a real database hater). So I will
certainly take a look at Pointres sometime...

Cheerz Lars

Jul 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Colin Steadman | last post by:
Hope this makes sense! I'm building an ASP page which allows uses to add items to an invoice via a form, ie: Item No Part No Order No Quanity Units Price VAT ------- ...
2
by: forums_mp | last post by:
I've got an STL class (see below) with two functions to store and retrieve data - msg structs. The "Store" function when called will copy the received message (depending on which message) into...
12
by: jacob nikom | last post by:
Hi, I would like to store XML files in MySQL. What is the best solution: 1. Convert it to string and store it as CLOB/text 2. Serialize it and store as byte array 3. Flatten it out and create...
7
by: Jenny | last post by:
Hi, I have a class foo which will construct some objects in my code. some of the objects store int values into the data deque, while others store float values to the deque. template <class...
5
by: Guadala Harry | last post by:
What are my options for *securely* storing/retrieving the ID and password used by an ASP.NET application for accessing a SQL Server (using SQL Server authentication)? Please note that this ID and...
3
by: ExclusiveResorts | last post by:
Can the CallContext be used reliably for storing request specific data? We are developing an application library that uses the CallContext to keep an IdentityMap (hashtable of business objects...
0
by: Harley | last post by:
I am trying to write a personal app to keep a bank balance and history. The problem I'm haveing is finding a decent way to store the data on a pocketpc under .net compact framewok useing vb.net....
6
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like...
0
by: sajenia | last post by:
i need to design a solid data store device. the prime use of the data store is to store text messages, with each message being structured as a linked list. the logical concept of the store will be a...
0
by: Brian Vanderburg II | last post by:
Lance Gamet wrote: Lance Gamet wrote: One way I've just started to use it to create a utility function to return the location of the user data folder, depending on the operating system: import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.