Bulk Insert from text file

Bulk Insert from text file

am 23.09.2008 22:25:30 von Nasreen Laghari

--0-1479990043-1222201530=:20671
Content-Type: text/plain; charset=us-ascii

Hi All,

I have bulk data store in text file, which is attached with this email. Could any 1 please help on how to insert using phpMyAdmin??

I tried using below code but getting "Error in SQL Syntax":

BULK
INSERT venue FROM 'c:\venues.txt'
WITH
( FIELDTERMINATOR = '","')



Any help will be appreciated.



Regards,


Nasreen



--0-1479990043-1222201530=:20671--

Insert a xml file into a DB

am 23.09.2008 22:45:19 von ERNESTO PENALOZA

Hi there, I've been trying to insert (and retrieve) a xml file into a
postgres DB into a BLOB field, using some nice examples downloaded from the
net, but they don't seem to work. Is there a "standard" way to do this?

I read about a bytea data type and run some examples, but never understood
how this data type works. When I retrieve the data, all I could see was a
number. What should I do with this number? How can I use it to see the xml
file content.?

Thank you in advance.


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Insert a xml file into a DB

am 23.09.2008 23:35:58 von Yves Sucaet

Why do you need to store the files in a database? Can't you just keep the=
m on
the hard disk and query them with DOM?


------ Original Message ------
Received: Tue, 23 Sep 2008 03:55:25 PM CDT
From: ERNESTO PENALOZA
To: php-db@lists.php.net
Subject: [PHP-DB] Insert a xml file into a DB

Hi there, I've been trying to insert (and retrieve) a xml file into a
postgres DB into a BLOB field, using some nice examples downloaded from t=
he
net, but they don't seem to work. Is there a "standard" way to do this?

I read about a bytea data type and run some examples, but never understoo=
d
how this data type works. When I retrieve the data, all I could see was a=

number. What should I do with this number? How can I use it to see the xm=
l
file content.?

Thank you in advance.


-- =

PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Insert a xml file into a DB

am 23.09.2008 23:57:29 von Matt Anderton

------=_Part_69164_11204467.1222207049723
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I'm with Yves -- just store the xml files on the local disk and then record
their *location* in the DB if you need to reference them.

if you really want to store the xml in the db, why not just use a 'text'
data type?

-- matt



On Tue, Sep 23, 2008 at 4:35 PM, YVES SUCAET wrote:

> Why do you need to store the files in a database? Can't you just keep them
> on
> the hard disk and query them with DOM?
>
>
> ------ Original Message ------
> Received: Tue, 23 Sep 2008 03:55:25 PM CDT
> From: ERNESTO PENALOZA
> To: php-db@lists.php.net
> Subject: [PHP-DB] Insert a xml file into a DB
>
> Hi there, I've been trying to insert (and retrieve) a xml file into a
> postgres DB into a BLOB field, using some nice examples downloaded from the
> net, but they don't seem to work. Is there a "standard" way to do this?
>
> I read about a bytea data type and run some examples, but never understood
> how this data type works. When I retrieve the data, all I could see was a
> number. What should I do with this number? How can I use it to see the xml
> file content.?
>
> Thank you in advance.
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

------=_Part_69164_11204467.1222207049723--

Re: Bulk Insert from text file

am 25.09.2008 04:37:38 von dmagick

Nasreen Laghari wrote:
> Hi All,
>
> I have bulk data store in text file, which is attached with this email.

Attachments never come through to the php mailing list(s). If anyone
asks for an attachment, place it somewhere on a website and provide a link.

Could any 1 please help on how to insert using phpMyAdmin??
>
> I tried using below code but getting "Error in SQL Syntax":
>
> BULK
> INSERT venue FROM 'c:\venues.txt'
> WITH
> ( FIELDTERMINATOR = '","')

http://dev.mysql.com/doc/refman/5.0/en/load-data.html

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Insert a xml file into a DB

am 25.09.2008 04:40:20 von dmagick

ERNESTO PENALOZA wrote:
> Hi there, I've been trying to insert (and retrieve) a xml file into a
> postgres DB into a BLOB field, using some nice examples downloaded from the
> net, but they don't seem to work. Is there a "standard" way to do this?
>
> I read about a bytea data type and run some examples, but never understood
> how this data type works. When I retrieve the data, all I could see was a
> number. What should I do with this number? How can I use it to see the xml
> file content.?

See examples here:

http://au.php.net/manual/en/function.pg-unescape-bytea.php

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Insert a xml file into a DB

am 25.09.2008 04:42:17 von dmagick

YVES SUCAET wrote:
> Why do you need to store the files in a database? Can't you just keep them on
> the hard disk and query them with DOM?



Postgres provides searching of xml documents using xpath and other such
functions:

http://www.postgresql.org/docs/8.3/static/functions-xml.html #FUNCTIONS-XML-PROCESSING

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: Bulk Insert from text file

am 25.09.2008 12:09:14 von Niel Archer

Hi

> Could any 1 please help on how to insert using phpMyAdmin??

I haven't used phpMyAdmin in years, but here's how I'd do it in SQL with
my favourite tool (SQLyog)

LOAD DATA LOCAL INFILE 'C:\file_name.txt'
INTO TABLE tbl_name
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(col_name1, col_name2, col_name3);

Some things to note.
1) the LOCAL keyword is for a file on YOUR computer. Remove it if the
file is located on the server. Many shared hosting packages do not
allow you to use LOCAL.

2) IGNORE 1 LINES assumes your file has column names or similar in the
first line, and ignores them. Remove if the file does not have any, or
increase the number if more than one non-data line at the start.

3) The two TERMINATED clauses define the line as being newline
terminated and fields separated by tabs. Change these accordingly. You
may need to add an extra backslash to escape the backslash for
phpMyAdmin, I do not remember how that works with phpMyAdmin.

--
Niel Archer



--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php