Bytea Example

Started by Naveen Kumarover 5 years ago13 messagesgeneral
Jump to latest
#1Naveen Kumar
naveenmcp@gmail.com

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Naveen Kumar (#1)
Re: Bytea Example

On 8/13/20 6:40 AM, Naveen Kumar wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

What programming language and database driver are you using?

--
Adrian Klaver
adrian.klaver@aklaver.com

#3Naveen Kumar
naveenmcp@gmail.com
In reply to: Adrian Klaver (#2)
Re: Bytea Example

I am trying to migrate the database from Oracle to PostgreSQL

On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

Show quoted text

On 8/13/20 6:40 AM, Naveen Kumar wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

What programming language and database driver are you using?

--
Adrian Klaver
adrian.klaver@aklaver.com

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Naveen Kumar (#3)
Re: Bytea Example

On 8/13/20 6:49 AM, Naveen Kumar wrote:

I am trying to migrate the database from Oracle to PostgreSQL

The question was:

What programming language and database driver are you using?

On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver <adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>> wrote:

On 8/13/20 6:40 AM, Naveen Kumar wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

What programming language and database driver are you using?

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

--
Adrian Klaver
adrian.klaver@aklaver.com

#5Naveen Kumar
naveenmcp@gmail.com
In reply to: Adrian Klaver (#4)
Re: Bytea Example

I am not using any programming language. I am simply using PostgreSQL 12
version that's all

On Thu, Aug 13, 2020 at 7:21 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

Show quoted text

On 8/13/20 6:49 AM, Naveen Kumar wrote:

I am trying to migrate the database from Oracle to PostgreSQL

The question was:

What programming language and database driver are you using?

On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver <adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>> wrote:

On 8/13/20 6:40 AM, Naveen Kumar wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

What programming language and database driver are you using?

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

--
Adrian Klaver
adrian.klaver@aklaver.com

#6Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Naveen Kumar (#5)
Re: Bytea Example

On 8/13/20 6:56 AM, Naveen Kumar wrote:

I am not using any programming language. I am simply using PostgreSQL 12
version that's all

I'm having a hard time figuring out how you are migrating from Oracle to
Postgres without using at least SQL and some sort of driver to pull out
of one and push into the other.

On Thu, Aug 13, 2020 at 7:21 PM Adrian Klaver <adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>> wrote:

On 8/13/20 6:49 AM, Naveen Kumar wrote:

I am trying to migrate the database from Oracle to PostgreSQL

The question was:

What programming language and database driver are you using?

On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver

<adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com>>> wrote:

     On 8/13/20 6:40 AM, Naveen Kumar wrote:
      > Can someone please give me an example on byteA data type.
      >
      > 1. How to import a image/text file into Bytea data type.?
      > 2. How to export the same?

     What programming language and database driver are you using?

     --
     Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

--
Adrian Klaver
adrian.klaver@aklaver.com

#7David G. Johnston
david.g.johnston@gmail.com
In reply to: Naveen Kumar (#1)
Re: Bytea Example

On Thursday, August 13, 2020, Naveen Kumar <naveenmcp@gmail.com> wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

At a simple level its no different than importing and exporting character
data using a “text/varchar” field or a number using an integer field. For
bytea the content is just raw bytes instead of characters or numbers.

David J.

#8Naveen Kumar
naveenmcp@gmail.com
In reply to: Adrian Klaver (#6)
Re: Bytea Example

sorry for the late reply. Below is my issue:

I am connected to PostgreSQL in a Windows environment. Below is my version:

*"PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit"*

I am just trying to practice LOB objects, like byteA data type, in
PostgreSQL. Unfortunately, I didn't find good links regarding this so I
raised the issue. Nothing else I am doing.

Thank you one and all !!

Thanks & Regards
Naveen

On Thu, Aug 13, 2020 at 7:34 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

Show quoted text

On 8/13/20 6:56 AM, Naveen Kumar wrote:

I am not using any programming language. I am simply using PostgreSQL 12
version that's all

I'm having a hard time figuring out how you are migrating from Oracle to
Postgres without using at least SQL and some sort of driver to pull out
of one and push into the other.

On Thu, Aug 13, 2020 at 7:21 PM Adrian Klaver <adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>> wrote:

On 8/13/20 6:49 AM, Naveen Kumar wrote:

I am trying to migrate the database from Oracle to PostgreSQL

The question was:

What programming language and database driver are you using?

On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver

<adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com>>> wrote:

On 8/13/20 6:40 AM, Naveen Kumar wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

What programming language and database driver are you using?

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

--
Adrian Klaver
adrian.klaver@aklaver.com

#9Francisco Olarte
folarte@peoplecall.com
In reply to: Naveen Kumar (#8)
Re: Bytea Example

Naveen:

1st, do not top post, it is frowned upon here. AAMOF I was tempted to
skip your message due to this, as it makes replying too hard.

AK asked you (twice), "What programming language and database driver
are you using?"

On Sun, Aug 16, 2020 at 7:11 PM Naveen Kumar <naveenmcp@gmail.com> wrote:

I am connected to PostgreSQL in a Windows environment. Below is my version:
"PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit"

AK question is relevant because pg is a client-server database. I
assume you have the server correctly installed and running, but we
need to know what client software you are using, i.e....

- "I'm using the bundled psql command line program."
In this case you interact by sending sql commands directly (I'm not
able to put a sample because I never use bytea from psql, but many on
this list do and can help you.

- "I'm using pgAdmin4", and some pgAdmin user can help you.

- "I'm using a C program using libpq"

- "I'm using a Java program using JDBC"

I am just trying to practice LOB objects, like byteA data type, in PostgreSQL. Unfortunately, I didn't find good links regarding this so I raised the issue. Nothing else I am doing.

There are lot of links, many people know them by heart, but you need
to help them by answering the question.

The driver/language phrasing in AK question is because normally no one
uses a plain sql ( psql/pgadmin) tool for LOBs, but if you do there
are links which can be provided.

Bear in mind that for all we know you could be connecting using your
own gopher based tool which translates coloquial swahili to sql.

Francisco Olarte.

#10Ron
ronljohnsonjr@gmail.com
In reply to: Francisco Olarte (#9)
Re: Bytea Example

OP originally wrote that he needs to exports and import them, so presumably
he's just using psql.

On 8/16/20 12:33 PM, Francisco Olarte wrote:

Naveen:

1st, do not top post, it is frowned upon here. AAMOF I was tempted to
skip your message due to this, as it makes replying too hard.

AK asked you (twice), "What programming language and database driver
are you using?"

On Sun, Aug 16, 2020 at 7:11 PM Naveen Kumar <naveenmcp@gmail.com> wrote:

I am connected to PostgreSQL in a Windows environment. Below is my version:
"PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit"

AK question is relevant because pg is a client-server database. I
assume you have the server correctly installed and running, but we
need to know what client software you are using, i.e....

- "I'm using the bundled psql command line program."
In this case you interact by sending sql commands directly (I'm not
able to put a sample because I never use bytea from psql, but many on
this list do and can help you.

- "I'm using pgAdmin4", and some pgAdmin user can help you.

- "I'm using a C program using libpq"

- "I'm using a Java program using JDBC"

I am just trying to practice LOB objects, like byteA data type, in PostgreSQL. Unfortunately, I didn't find good links regarding this so I raised the issue. Nothing else I am doing.

There are lot of links, many people know them by heart, but you need
to help them by answering the question.

The driver/language phrasing in AK question is because normally no one
uses a plain sql ( psql/pgadmin) tool for LOBs, but if you do there
are links which can be provided.

Bear in mind that for all we know you could be connecting using your
own gopher based tool which translates coloquial swahili to sql.

Francisco Olarte.

--
Angular momentum makes the world go 'round.

#11Avinash Kumar
avinash.vallarapu@gmail.com
In reply to: Naveen Kumar (#5)
Re: Bytea Example

Hi Naveen,

It's not easy for us to read if you top post. Always reply inline please.

On Thu, Aug 13, 2020 at 10:57 AM Naveen Kumar <naveenmcp@gmail.com> wrote:

I am not using any programming language. I am simply using PostgreSQL 12
version that's all

Oracle has BLOB to store Binary data and PG has BYTEA.

In case you want to practice something like reading an image of your choice
and storing the binary data in a table *using Python and psycopg2*, you
could use the following example :

https://www.postgresqltutorial.com/postgresql-python/blob/

You would use some programming language and database driver to read or
write such binary data usually, so the question was what were you using to
practice or implement this migration stuff ?
and
What are you using to migrate the data from Oracle to PostgreSQL ?
and
What is the challenge in copying binary data from Oracle to PostgreSQL ?

On Thu, Aug 13, 2020 at 7:21 PM Adrian Klaver <adrian.klaver@aklaver.com>
wrote:

On 8/13/20 6:49 AM, Naveen Kumar wrote:

I am trying to migrate the database from Oracle to PostgreSQL

The question was:

What programming language and database driver are you using?

On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver <

adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com>> wrote:

On 8/13/20 6:40 AM, Naveen Kumar wrote:

Can someone please give me an example on byteA data type.

1. How to import a image/text file into Bytea data type.?
2. How to export the same?

What programming language and database driver are you using?

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Regards,
Avinash Vallarapu

#12Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Naveen Kumar (#8)
Re: Bytea Example

On 8/16/20 10:10 AM, Naveen Kumar wrote:

sorry for the late reply. Below is my issue:

I am connected to PostgreSQL in a Windows environment. Below is my version:

*"PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit"*

I am just trying to practice LOB objects, like byteA data type, in
PostgreSQL. Unfortunately, I didn't find good links regarding this so I
raised the issue. Nothing else I am doing.

Some simple examples:

create table bytea_test(byte_fld bytea);

insert into bytea_test values('\xDEADBEEF');

select * from bytea_test ;
byte_fld
------------
\xdeadbeef

insert into bytea_test values(decode('test string', 'escape'));

select * from bytea_test ;
byte_fld
--------------------------
\xdeadbeef
\x7465737420737472696e67

select encode(byte_fld, 'escape') from bytea_test ;
encode
------------------
\336\255\276\357
test string

From docs:

https://www.postgresql.org/docs/12/datatype-binary.html

https://www.postgresql.org/docs/12/functions-binarystring.html

As pointed out by Francisco Olarte the above generally does not happen
directly in database. Usually you are using some external program to
convert the binary data into some form of bytea.

Thank you one and all !!

Thanks & Regards
Naveen

On Thu, Aug 13, 2020 at 7:34 PM Adrian Klaver <adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>> wrote:

On 8/13/20 6:56 AM, Naveen Kumar wrote:

I am not using any programming language. I am simply using

PostgreSQL 12

version that's all

I'm having a hard time figuring out how you are migrating from
Oracle to
Postgres without using at least SQL and some sort of driver to pull out
of one and push into the other.

On Thu, Aug 13, 2020 at 7:21 PM Adrian Klaver

<adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com>>> wrote:

     On 8/13/20 6:49 AM, Naveen Kumar wrote:
      > I am trying to migrate the database from Oracle to PostgreSQL

     The question was:

     What programming language and database driver are you using?

      >
      > On Thu, Aug 13, 2020 at 7:17 PM Adrian Klaver
     <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>

      > <mailto:adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com>

     <mailto:adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com>>>> wrote:

      >
      >     On 8/13/20 6:40 AM, Naveen Kumar wrote:
      >      > Can someone please give me an example on byteA data

type.

      >      >
      >      > 1. How to import a image/text file into Bytea data

type.?

      >      > 2. How to export the same?
      >
      >     What programming language and database driver are you

using?

      >
      >     --
      >     Adrian Klaver
      > adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com> <mailto:adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>>

     <mailto:adrian.klaver@aklaver.com

<mailto:adrian.klaver@aklaver.com> <mailto:adrian.klaver@aklaver.com
<mailto:adrian.klaver@aklaver.com>>>

      >

     --
     Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

<mailto:adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>>

--
Adrian Klaver
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.com>

--
Adrian Klaver
adrian.klaver@aklaver.com

#13David G. Johnston
david.g.johnston@gmail.com
In reply to: Naveen Kumar (#8)
Re: Bytea Example

On Sun, Aug 16, 2020 at 10:11 AM Naveen Kumar <naveenmcp@gmail.com> wrote:

*"PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit"*

I am just trying to practice LOB objects, like byteA data type, in
PostgreSQL. Unfortunately, I didn't find good links regarding this so I
raised the issue. Nothing else I am doing.

You should supply code that demonstrates what you have tried so far and the
errors you are getting (or commented out pseudocode in the places where you
are not sure what to write).
David J.