Gossamer Forum
Home : Products : DBMan : Customization :

Modify Existing DB

Quote Reply
Modify Existing DB
Is there an easy way to add fields to an existing DBMan DB? I have a database that has over 1000 records and we are currently looking into completely redoing the site. We would like to include adding at least 3 new fields to our existing DB. The new fields could be added to the end of our existing database - would that be all that we have to do? Also, is there a script or program that could add the delimiters needed for the 3 new fields to the file for us without having to manually add them?

--------------
donm
Quote Reply
Re: Modify Existing DB In reply to
You can just add | characters for each new field to the end of each record.

You should be able to do a search-and-replace in a text editor. If you text editor will allow you to search for "\n" -- the newline character --

search for
\n

replace with
| | |\n
(no spaces, even though UBB will show some).

I know that EditPlus will allow you to do this.

Keep a back up of your original data, just in case.

------------------
JPD







[This message has been edited by JPDeni (edited August 15, 1999).]
Quote Reply
Re: Modify Existing DB In reply to
I have just written a Perl script that will add fields to your database file. It is based on the upgrade.pl file available for LINKS. But I have modified it considerably and also added in some more user friendly variables.

If you would like a copy of this upgrade.cgi file, please contact me via email at eliot@anthrotech.com.

The file is quite large and it would be cumbersome if I posted the codes in this Thread.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Modify Existing DB In reply to
JPDeni wouldn't that leave them with the userid field four fields back?

|userid| ||\n
Quote Reply
Re: Modify Existing DB In reply to
Yes, it would leave the userid four fields back. But it doesn't matter.

Let's say your current %db_def includes:

Code:
Validated => [7, 'alpha', 0, 3, 1, 'Yes', 'Yes|No'],
Popular => [8, 'alpha', 0, 3, 0, '', ''],
Userid => [9, 'alpha', -2, 15, 0, '', '']

So that the last few fields in your .db file are

Code:
|Yes|Yes|fred
|Yes|No|wilma
|No|No|barney
|No|Yes|betty

and your $auth_user_field = 9.

Now you want to add some more fields:

Code:
Userid => [9, 'alpha', -2, 15, 0, '', ''],
City => [10, 'alpha', 40, 40, 1, '', ''],
State => [11, 'alpha', 0, 2, 1, '', ''],
Country => [12, 'alpha', 0, 40, 0, '', '']


You would add the three | characters to your .db file:

Code:
|Yes|Yes|fred| | |
|Yes|No|wilma| | |
|No|No|barney| | |
|No|Yes|betty| | |

But your $auth_user_field would still be field 9. No difference.

Unless I'm completely misunderstanding your question.


------------------
JPD







[This message has been edited by JPDeni (edited August 15, 1999).]
Quote Reply
Re: Modify Existing DB In reply to
I just took a look at my current default.db and see that each line ends with "|", so I can't do a replace "\n" with "| ||\n". Any other suggestions?

Quote Reply
Re: Modify Existing DB In reply to
You might want to try the script that I created that will add fields to your existing database file. If you want it, email me.

Regards,

------------------
Eliot Lee
Founder and Editor
Anthro TECH, L.L.C
http://www.anthrotech.com/
info@anthrotech.com
==========================
Coconino Community College
http://www.coco.cc.az.us/
Web Technology
Coordinator
elee@coco.cc.az.us
Quote Reply
Re: Modify Existing DB In reply to
If each line in your current .db file ends with a |, that means that you have a field at the end which has no data in any record.

It still doesn't matter if it ends with a | or with betty or anything else. There is a newline character at the end of every line. You can't see it, but it's there. If it wasn't everything would be one one line.

Back up your database. Then open a copy of the database in a text editor. Do a search and replace like I told you. Change your .cfg file to include the other three fields. Then upload the whole mess and see what happens.


------------------
JPD





Quote Reply
Re: Modify Existing DB In reply to
JPDeni - you are correct again ! I did exactly as you said (downloaded editplus) and edited my existing DB as instructed and presto - everything is still in it's proper place and I now have the additional fields ! You have saved me sooooooooo much manual typing. I think one or two of those Amazon gift certificates might be in order once I have all this completed ! <g> I hope you do realize how much your help here is appreciated ! Thanks again ! Now I have to get back to adding more mods (adding them one at a time to make sure everything is working properly)

---------------
donm
Quote Reply
Re: Modify Existing DB In reply to
Excellent! Wink





[This message has been edited by JPDeni (edited August 15, 1999).]
Quote Reply
Re: Modify Existing DB In reply to
Wait, hold up. I'm an avid EditPlus fan. My perl code is color coded, and sometimes it completes commands for me, but how do you get it to check for syntax?

I do have Perl on my machine.