View Full Version : Storing HTML in Postgres


Luperci
02-01-08, 09:32 AM
Does any one know of a good way to store a html document in Postgres? It’s a simple page with two pictures. I’m trying to figure out if it’s worth it or just take a picture of the page and store that. Any thoughts?

Here’s the code to the page:
<html>
<head>
<title>BioCalculator Result</title>
</head>
<body>
<div align='center'>
C:\Documents and Settings\Victor\Desktop\HPV\HPV test #3-A-04
</div>
<div align='center'>
<img align='middle' src='HPV test #3-A-04.jpg' width='600' height='300'>
</div>
<div align='center'>
<img align='middle' src='HPV test #3-A-04Gel.jpg' width='600' height='50'>
</div><br>
<table border='1' align='center'>
<tr>
<td><font size='2'>nr</font></td>
<td><font size='2'>name</font></td>
<td><font size='2'>time</font></td>
<td><font size='2'>reltime</font></td>
<td><font size='2'>start</font></td>
<td><font size='2'>stop</font></td>
<td><font size='2'>height</font></td>
<td><font size='2'>height%</font></td>
<td><font size='2'>na</font></td>
<td><font size='2'>na%</font></td>
<td><font size='2'>R</font></td>
<td><font size='2'>size (bp)</font></td>
<td><font size='2'>conc (ng/ul)</font></td>
</tr>
<tr>
<td><font size='2'>1</font></td>
<td><font size='2'></font></td>
<td><font size='2'>3.545</font></td>
<td><font size='2'>0.0000</font></td>
<td><font size='2'>3.512</font></td>
<td><font size='2'>3.569</font></td>
<td><font size='2'>0.9577</font></td>
<td><font size='2'>0.00</font></td>
<td><font size='2'>0.000E+000</font></td>
<td><font size='2'>0.00</font></td>
<td><font size='2'>0.000</font></td>
<td><font size='2'>0.0</font></td>
<td><font size='2'>0.00</font></td>
</tr>
<tr>
<td><font size='2'>2</font></td>
<td><font size='2'></font></td>
<td><font size='2'>3.807</font></td>
<td><font size='2'>0.0505</font></td>
<td><font size='2'>3.729</font></td>
<td><font size='2'>3.863</font></td>
<td><font size='2'>0.1484</font></td>
<td><font size='2'>11.81</font></td>
<td><font size='2'>1.385E-003</font></td>
<td><font size='2'>18.56</font></td>
<td><font size='2'>22.031</font></td>
<td><font size='2'>46.2</font></td>
<td><font size='2'>0.00</font></td>
</tr>
<tr>
<td><font size='2'>3</font></td>
<td><font size='2'></font></td>
<td><font size='2'>6.599</font></td>
<td><font size='2'>0.5896</font></td>
<td><font size='2'>6.529</font></td>
<td><font size='2'>6.708</font></td>
<td><font size='2'>1.1079</font></td>
<td><font size='2'>88.19</font></td>
<td><font size='2'>6.080E-003</font></td>
<td><font size='2'>81.44</font></td>
<td><font size='2'>14.932</font></td>
<td><font size='2'>409.9</font></td>
<td><font size='2'>0.00</font></td>
</tr>
<tr>
<td><font size='2'>4</font></td>
<td><font size='2'></font></td>
<td><font size='2'>8.724</font></td>
<td><font size='2'>1.0000</font></td>
<td><font size='2'>8.691</font></td>
<td><font size='2'>8.877</font></td>
<td><font size='2'>1.0446</font></td>
<td><font size='2'>0.00</font></td>
<td><font size='2'>0.000E+000</font></td>
<td><font size='2'>0.00</font></td>
<td><font size='2'>0.000</font></td>
<td><font size='2'>0.0</font></td>
<td><font size='2'>0.00</font></td>
</tr>
<tr>
<td><font size='2'>5</font></td>
<td><font size='2'></font></td>
<td><font size='2'></font></td>
<td><font size='2'></font></td>
<td><font size='2'></font></td>
<td><font size='2'></font></td>
<td><font size='2'></font></td>
<td><font size='2'>100.00</font></td>
<td><font size='2'>7.466E-003</font></td>
<td><font size='2'>100.00</font></td>
<td><font size='2'></font></td>
<td><font size='2'>456.1</font></td>
<td><font size='2'>0.00</font></td>
</tr>
</table>
</body>
</html>

Stryder
02-01-08, 11:29 AM
This might not be of use to you but I'll mention it anyway.

Once upon a time I had a MySQL server rigged up on a server that I could directly access, you can pretty much rig up a server yourself with little problem either by installing it on a Linux server or just running a Binary on the machine you are working on.

I used OpenOffice to have a number of spreadsheets for dealing with some commodity trading in the EVE-Online game, to be able to identify the prices of things to my corporation at the time, I used the inbuilt method of OpenOffice to update the Tables that existed in the MySQL database.

Quite simply if you have a database available for use, you can actually populate and update (append) via the use of OpenOffice, which was very handy at the time. It would take some messing around for a person to get use to it and obviously some Web service providers don't allow direct access to databases making it impossible to use OpenOffice to update the database. (This is where webpages for parsing data have to be used)

For the most part if you are only dealing with limited amounts of data you don't need to even use a database but use something like a Comma seperated values (.cvs) However it's really down to the size of the data you are trying to store and the number of accesses you are looking at (and whether there administrative access for altering the data too).

RubiksMaster
02-01-08, 05:13 PM
I don't know much about Postgres specifically, because I use MySQL. With that disclaimer...

In database systems, the data type you are looking for is called a CLOB (character large object). I've heard tell that Postgres doesn't have good (if any) CLOB support though. But, I'm sure you could just store the flat file in a BLOB (binary large object), because if I'm not mistaken, it does handle BLOBs decently.

Luperci
02-04-08, 07:12 AM
Thanks, Rubiks I'll try that.

Quantic
02-05-08, 07:19 PM
Luperci, I agree with RubiksMaster. BLOBs are probably best; I've stored JPEG images that way and if you're using Perl, I can show you code that puts the data in the database and gets it out again.

Luperci
02-05-08, 10:23 PM
Using BLOBs was the way to go. And Quantic thanks for the offer on the Perl code. I've been looking for a good forum to discuss coding questions. Are there many programmers on this site, or is it mainly gammers?

Quantic
02-06-08, 07:10 AM
I don't know what the demographics of this site are. There seem to be a wide variety of people here that post messages. I would be lumped among the programmers and science enthusiasts...

RubiksMaster
02-06-08, 10:12 PM
Are there many programmers on this site, or is it mainly gammers?
There are a fair number of programmers here with ranging levels of experience. Maybe not as many as an actual programming forum, but there's several people I can think of off the top of my head that know a fair deal.

I like to think I'm decent. I do it for my job. If you want to discuss coding, feel free to make a thread. I actually wish there were more programming discussions on here.