Обсуждение: Storing Media Types

Поиск
Список
Период
Сортировка

Storing Media Types

От
Carlos Mennens
Дата:
I've created a basic table called 'employees' & I've been asked to
store a profile photo of all employees. I've looked on Google and the
9.0 documentation but can't find any clear instructions on how I would
be to insert photo's stored in a local directory on the server
(/var/lib/postgres/data/media/pics). I'm trying to understand how I
would create an entry into the table I show below to be able to add
photo's for each user. Does anyone have an example of what the code
would look like and or offer any assistance?


ghost=> CREATE TABLE employees
(
id INT PRIMARY KEY NOT NULL UNIQUE,
fname VARCHAR(50) NOT NULL,
lname VARCHAR(50) NOT NULL,
email VARCHAR(50) UNIQUE NOT NULL,
branch VARCHAR(50) NOT NULL,
position VARCHAR(50) NOT NULL,
office INT NOT NULL,
dob DATE NOT NULL,
photo ?
)
;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"employees_pkey" for table "employees"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index
"employees_email_key" for table "employees"
CREATE TABLE

-Carlos

Re: Storing Media Types

От
"David Johnston"
Дата:
Photos/Images are binary data and thus should be placed into a "bytea" typed
field.  As to HOW you would identify and load the binary data that would be
depending upon your programming language and user interface.  If you are
using a traditional programming language you would simply create a
parameterized INSERT statement and then specify that the contents of the
binary file would be loaded into that particular parameter.

You do NOT explicitly put the binary data into the PostgreSQL's data
directory (which you appear to be implying).

IF you want to use psql/pgAdmin running on the server to load in a local
file you should specify that and wait (or look) for a proper response as I
do not know how or if that can be done.

David J

-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Carlos Mennens
Sent: Wednesday, February 09, 2011 7:30 PM
To: pgsql-general@postgresql.org
Subject: [GENERAL] Storing Media Types

I've created a basic table called 'employees' & I've been asked to store a
profile photo of all employees. I've looked on Google and the
9.0 documentation but can't find any clear instructions on how I would be to
insert photo's stored in a local directory on the server
(/var/lib/postgres/data/media/pics). I'm trying to understand how I would
create an entry into the table I show below to be able to add photo's for
each user. Does anyone have an example of what the code would look like and
or offer any assistance?


ghost=> CREATE TABLE employees
(
id INT PRIMARY KEY NOT NULL UNIQUE,
fname VARCHAR(50) NOT NULL,
lname VARCHAR(50) NOT NULL,
email VARCHAR(50) UNIQUE NOT NULL,
branch VARCHAR(50) NOT NULL,
position VARCHAR(50) NOT NULL,
office INT NOT NULL,
dob DATE NOT NULL,
photo ?
)
;
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index
"employees_pkey" for table "employees"
NOTICE:  CREATE TABLE / UNIQUE will create implicit index
"employees_email_key" for table "employees"
CREATE TABLE

-Carlos

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general