Converting a flatfile to sql

They have: 4 posts

Joined: Jun 2005

I have a program on my website called wwwPaint that uses a flatfile database file. The problem is that now I have hundreds of members, drawings, and comments that are all stored in a non-encrypted, very basic text file and it has become quite the load on the server, and slows the page down considerably.

Im looking for a way to convert the program over to use a sql database instead, mainly to relive the load somewhat, and speed it up.

The text file its self is basic it contains the variables seperated with a | pipe character, so one entry might look like this

Date|drawing name|drawing comments|username|points|email|votes|last updated|item number|

How can I convert this basic flatfile database to use a mysql database instead? I realize this would require the code to be modified but how hard its it to do in reality?

Anyways Im kinda desperate here, its getting slower and slower, and I could delete some but thats not going to solve it I want them all.

Please someone if you can help, let me know my options, I would be much appreciated.

Best Regards;
Robert

Busy's picture

He has: 6,151 posts

Joined: May 2001

Set up your table in phpmyadmin or similar then import the text file, you might have to change the pipes to commas and rename the file .cvs - depending what version/options you have

They have: 4 posts

Joined: Jun 2005

Thanks for responding;

ok that imports it, but this file is always being updated? how to I tell the software to now use mysql as its db, instead of look for data in the db.php file in its directory?

Everytime someone saves it creates a new entry and reads from it aswell to check the next available file number.

Would it help any if I send over the code? its only a handful of php files + 2 seperate flatfile databases + an image folder . The 2nd db holds the only the usercomments for the drawings, that can remain a flatfile, unless it can be intregrated easy.

This is going to require software modification as I see it, or perhaps the db.php file can refer to a sqldatabase. Im afraid im not that good with databases, I do understand basic functions and calls, and can modify existing code by trial and error, but this will require new code Im not familiar with.

ps: version numbers are:

PHP Version 4.3.10
Mysql Version 4.0.22-standard

Best Regards;
Robert

Busy's picture

He has: 6,151 posts

Joined: May 2001

You will just need to change the code so instead of opening and writing to a flat file it opens and stores to your database.

If you know basic function etc this would be the perfect chance to advance what you know (it's not hard). Do a search for mysql beginners tutorial
All you need is:
connect to database (instead of opening file)
insert into database (instead of write to file)

and to display from the database is just:
connect to database (instead of opening file)
select from database (instead of from flat file)

They have: 4 posts

Joined: Jun 2005

lol,

I guess I should of specified, I know basic php functions and calls, and installation of scripts. I dont know anything about db writing/reading via either method. I would be guessing and doing it blindfolded moreless.

would you reccomend a anyone whom I could contract this out to? Im being told that is fairly easy but would require analisis of the existing code, then writing the script, creating the tables debuging, and so on, I would rather pay someone and have it done right the first time.

Thank you for your help, If you should know of a decent programmer that would do it for a reasonable amount please let me know.

Best Regards;
Robert

timjpriebe's picture

He has: 2,667 posts

Joined: Dec 2004

I searched Google for "php db tutorial" and it looks like there's plenty of results. I would suggest looking through some of those and see if they would be of help.

It's always best to make the time to teach yourself how to do it, if you can.

The first tutorial Google listed looked decent enough, though I only skimmed over it.

http://www.phpbuilder.com/columns/allan20010115.php3

They have: 4 posts

Joined: Jun 2005

Anyways all I asked for was the name of a decent sql programmer, I have way too much on my plate with other commitments, and my site makes me enough money I can just pay someone to do it Smiling

I do appreciate your good business practices, not long ago I would have had to do that but now am able to splurge a bit..

This one program is reakin havoc its not written as anything ive ever seen, it looks like its C mixed with php, and Java, and while I did mod and customize it alot, databases I are not my thing. not to mention it uses 3 seperate databases (only 1 of which im concerened about)..

Im not normally left with this issue when i build a site for a customer I build a template and layout , implement what what customer needs, create the pages, install the software, set up a db's , verify, tweak, finalize smalll details with the client and im done!

This really iis custom work, that rquires more then just SQL 101 and a few queries I need someone advanced, to do this.

I wrote my site on my own, and quite honestly it is much nicer then atleast 50% out there, thats being modest, I put my heart into it (as any true webdesigner would).. as I do for my customers, but this is a different Im not trained in this the jobs up for grabs.!

Thank again! ..

Best Regards;
Robert L
https://insarnia.ca

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.