[Zope-dev] How to insert time use mysql connection!

TMGB bennettt@am.appstate.edu
Wed, 02 Feb 2000 10:08:47 -0500


There is probably several ways to do autoincrement with Zope and or
python methods but I use the built in feature of MySQL.  It doesn't have
to be the first field of the database but here is the syntax to add an
autoincrement field to an existing MySQL database:

ALTER table mytable ADD ID INT NOT NULL AUTO_INCREMENT;

This adds a field called ID to a table named mytable in MySQL.  Of
course you can change ID to any text.  In the example I sent you the
NULL was the first parameter in the Zsql method because ID is the first
field in my database.  You can use the command above at the MySQL prompt
or you should be able to do it from a Zsql method using the test option,
I suggest only testing it once I suppose you will just get an error
message if you try to recreate the same field again.  I actually use
this for the record number which allows me to bring up a unique record
according to record number because data in some other fields might be
replicated.  I don't know if MySQL  has record numbers built in, I don't
think so.

Thomas


Victor.Zhai@ogilvy.com wrote:
> 
> Dear:
>   What you said is just the requirment of my project, I want to one field
> is an auto increment integer when user use one form
> to add something into my database.
>   Should I modify my database structure.Make Null the first fields of the
> database? is there any other method to do that?
>   How to realize the auto increment integer?
> Please give me some advice.
> Thanks a lot!
> Victor zhai.
> 
> "WorldSecure Server <ogilvy.com>" made the following
>  annotations on 01/31/00 22:49:42
> ------------------------------------------------------------------------------
> Privileged/Confidential Information may be contained in this message.  If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer does not consent to email for messages of this kind.  Opinions, conclusions and other information in this message that do not relate to the official business of the Ogilvy Group shall be understood as neither given nor endorsed by it.
> 
> ==============================================================================

-- 
--------------------------------------------------------------------
                      Rock and Rule
             Zope Rocks -- http://www.zope.org
           Python Rules  -- http://www.python.org    
--------------------------------------------------------------------
Thomas McMillan Grant Bennett      Appalachian State University
Computer Consultant II             University Library
bennettt@am.appstate.edu          
http://www.library.appstate.edu/webmaster/
Voice:  828 262 6587	           FAX:    828 262 3001

Windows 95 is a 32-bit extension to a 16-bit patch for an 8-bit
operating system that was originally coded for a 4-bit microprocessor.
 - Chris Dunphy     Boot Magazine