Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Dump data from unicode database

by sachin raj aryan (Acolyte)
on Jun 30, 2021 at 12:29 UTC ( #11134486=note: print w/replies, xml ) Need Help??


in reply to Re: Dump data from unicode database
in thread Dump data from unicode database

my $sql1 = "select deptid,to_char(a.epfno) epfno,a.ename ename,desi +g,decode(b.status,'P','उपस्थि&#23 +40;','A','अवकाश','D','प्&#2 +352;तिनियुक्त&# +2367;') status,b.rmk from Atnd_emp_mast a,Atnd_position b where repoid=1 and I +SACTIVE=0 and a.epfno=b.epfno and SUMM_HOD_FLAG=1 and ATTEN_DT=to_date('17-12-2020','DD-MM-YYYY') order by SUMM_SORTID"; + $sth =$dbh->prepare($sql1); $sth->execute(); my @rows =$sth->fetchrow_array; while (@rows=$sth->fetchrow_array) { binmode(STDOUT, ":utf8"); print join(",",@row),"\n"; }

made changes its still not working

Replies are listed 'Best First'.
Re^3: Dump data from unicode database
by Tux (Canon) on Jun 30, 2021 at 12:52 UTC

    ENOTENOUGHINFO: you have told us nothing about the database, its version, its encoding, its network layers etc etc.

    $ cat info.csv id,count,desc,asc,row 1,2,foo,bar,10 $ perl -MDBI -COE -wE'my$dbh=DBI->connect("dbi:CSV:",undef,undef,{f_ex +t=>".csv/r"});my$sth=$dbh->prepare("select id,\x27\x{20ac}\x27 from i +nfo");$sth->execute;while(my$r=$sth->fetch){say for@$r;}' 1

    That just worked, so it could be your database or your database driver, or your database driver version or ...


    Enjoy, Have FUN! H.Merijn
Re^3: Dump data from unicode database
by bliako (Monsignor) on Jun 30, 2021 at 13:03 UTC

    is the DB set up to store unicode? is what you store in DB unicode? is what you get out from DB encoded as unicode?

    placing a binmode(STDOUT, ":encoding(utf-8)"); (thanks Tux) at the beginning of your script will display unicode to STDOUT and complain if it contains invalid bytes. But you may need to tell your db to store unicode (for mysql it used to be something like this during table construction: mysql_enable_utf8mb4) and make DBI::connect aware with mysql_enable_utf8 => 1. For some cases you need to explicitly encode the bytes received from DB into unicode using Encode::encode... or investigate if it's a case of double encoding using Encode::decode...

A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11134486]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2022-01-19 15:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (55 votes). Check out past polls.

    Notices?