angie ahl | 1 Dec 2004 15:26
Picon

Unicode (utf8) and MySQL (with Perl)

Hi List.

Please excuse the cross posting but I've been scouring the archives
and no joy as yet.

I'm trying to get Perl and MySQL using utf8 happily and I've followed
several tutorials but am not getting the same results.

I've got a load of utf8 characters like so (perl):

my %uni = (
        hebrew_alef => {
                character => chr(0x05d0),
                language => "hebrew",
        },
        smiley => {
                character => "\x{263a}",
                language => "none",
        },
);

I am inserting them into MySQL using the dbi module DBD::MySQL

The tutorial said to insert the values like this:
	INSERT INTO unitest (id, aword) VALUES ( "smiley",
CONVERT(_utf8'\x{263a}' USING utf8) );

get the values back like this:
	select aword from unitest where id = "smiley;"
	
(Continue reading)

Rhino | 1 Dec 2004 16:27
Picon
Favicon

Re: Unicode (utf8) and MySQL (with Perl)


----- Original Message ----- 
From: "angie ahl" <angie.ahl <at> gmail.com>
To: <mysql <at> lists.mysql.com>; <perl <at> lists.mysql.com>
Sent: Wednesday, December 01, 2004 9:26 AM
Subject: Unicode (utf8) and MySQL (with Perl)

> Hi List.
>
> Please excuse the cross posting but I've been scouring the archives
> and no joy as yet.
>
> I'm trying to get Perl and MySQL using utf8 happily and I've followed
> several tutorials but am not getting the same results.
>
> I've got a load of utf8 characters like so (perl):
>
> my %uni = (
>         hebrew_alef => {
>                 character => chr(0x05d0),
>                 language => "hebrew",
>         },
>         smiley => {
>                 character => "\x{263a}",
>                 language => "none",
>         },
> );
>
> I am inserting them into MySQL using the dbi module DBD::MySQL
>
(Continue reading)

Darren Duncan | 1 Dec 2004 20:16
Favicon

Re: Unicode (utf8) and MySQL (with Perl)

On Wed, 1 Dec 2004, Rhino wrote:
> > I'm using mysql 4.1.7 and perl 5.8.1 on OS X 10.3

It also wouldn't hurt you to upgrade past all the minor updates of your 
other components.  That means 4.1.7 (check), 5.8.6, and 10.3.6.  I'm sure 
Perl had a lot of bug fixes or improvements after 5.8.1, especially since 
Unicode support is used a lot less than ascii historically.  Also, make 
sure you have DBI 1.46 and DBD::mysql the newest. -- Darren Duncan

--

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules <at> m.gmane.org

angie ahl | 1 Dec 2004 23:19
Picon

Re: Unicode (utf8) and MySQL (with Perl)

Just thought I'd send this for the record to the perl mysql list.

Here's a brief summary of what I needed to do to get unicode working
happily with Perls DBI DBD::MySQL and MySQL.

I'm using Perl 5.8.1 and MySQL 4.1.7

Web pages are encoded as utf-8 and put together using cgi.pm

The following 3 things are used at the start of  the perl script:

use utf8; #tells perl that I will be using utf8 in the script itself.
use Encode qw/is_utf8 decode/; #allows me to decode utf8 strings and test them
binmode(STDOUT, ":utf8"); #prints characters in utf8

The web page is started with utf8 encoding using cgi:
        print start_html(-encoding => 'utf-8',-title => "Simple UTF 8 test");

I used cgi to pass utf data to the next page and then decoded it into
a variable:
my $univalue = decode("utf8", param("param_name"));

I have a table in MySQL whose charset is utf8,
Here's the bit that's not mentioned much: 
When opening the connection to the DB using DBI I needed to tell it
that I wanted the connection to use utf8.
So I connected as usual:

        my $dsn = "dbi:mysql:database=$dbname;host=$dbhost"; 
        my $dbh = DBI->connect($dsn, $dbun, $dbpw);
(Continue reading)

KPenner | 2 Dec 2004 22:33

Newline character in TEXT field.

I am trying to read in a text file and save it to a TEXT field in a MySQL database using perl 5.8. (DBI::MySQL). 
The file has CRLFs in it but when it is saved to the database is only has LFs.

I read in the file like this:

      # Open input file of data
    open( FILEIN, "$directory\\$fname" )    || die "can't open $fname $!";
    undef $/;
    $text = <FILEIN>;
    close FILEIN;

My SQL statement is:

my $sth2 = $dbh->prepare( "Insert into reports
                           (type, ext, date, text, name, clientspec)
                           Values ( ?, ?, ?, ?, ?, ? )" );

and my execute statement is:

       $sth3->execute( $type, $ext, $date, $text, $name, $clientspec, $name );

Is there some way to control what the newline character is when doing this?

ps.  My co-worker is doing the same thing in PHP and is getting the full CRLF in the field.

Thanks,

Kevin M. Penner
Programmer
Call_Solutions
(Continue reading)

DAY,AARON GARTH | 3 Dec 2004 01:28
Favicon

DBD::mysql not installing!! Help!!

I've already installed the DBI module and Data-Show-Table modeule and
there were not errors in their installation.  But when I perform the
command:  perl Makefile.PL  I get the following comments:

Unsuccessful stat on filename containing newline at
/usr/lib/perl5/5.8.0/ExtUtils/Liblist/Kid.pm line 97. [REPATED 116 TIMES]

Using DBI 1.46 (for perl 5.008 on i386-linux-thread-multi) installed in
/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/auto/DBI/

Writing Makefile for DBD::mysql

Then when I type make I get:

Makefile:89: *** missing separator.  Stop.

what do I need to do?????  Thanks for the help

AGD

--

-- 
MySQL Perl Mailing List
For list archives: http://lists.mysql.com/perl
To unsubscribe:    http://lists.mysql.com/perl?unsub=gcdmp-msql-mysql-modules <at> m.gmane.org

Rick Measham | 3 Dec 2004 02:04

Re: DBD::mysql not installing!! Help!!

You don't say what OS, but I'm going to guess it's RedHat 9?

It's a Unicode problem that we had a lot with DateTime installations on
RH9. To get it to work, prepend the recipe with a null language
variable:

LANG=; perl Makefile.PL
make
make test
make install

That will stop it trying to go all unicode on you, and the problems with
the makefile will stop.

If I've guessed wrong, then accept my appologies and let us know which
distro you're using.

Cheers!
Rick Measham

On Fri, 2004-12-03 at 11:28, DAY,AARON GARTH wrote:
> I've already installed the DBI module and Data-Show-Table modeule and
> there were not errors in their installation.  But when I perform the
> command:  perl Makefile.PL  I get the following comments:
> 
> 
> Unsuccessful stat on filename containing newline at
> /usr/lib/perl5/5.8.0/ExtUtils/Liblist/Kid.pm line 97. [REPATED 116 TIMES]
> 
> Using DBI 1.46 (for perl 5.008 on i386-linux-thread-multi) installed in
(Continue reading)

DAY,AARON GARTH | 3 Dec 2004 02:09
Favicon

Re: DBD::mysql not installing!! Help!!

Rick,

You guessed correctly, I'm using RH9.  Thank you so muck for getting back
to me so quickly.  I'll do it now.

Thanks,

AGD

Quoting Rick Measham <rickm <at> 3d3.com>:

> You don't say what OS, but I'm going to guess it's RedHat 9?
>
> It's a Unicode problem that we had a lot with DateTime installations on
> RH9. To get it to work, prepend the recipe with a null language
> variable:
>
> LANG=; perl Makefile.PL
> make
> make test
> make install
>
> That will stop it trying to go all unicode on you, and the problems
> with
> the makefile will stop.
>
> If I've guessed wrong, then accept my appologies and let us know which
> distro you're using.
>
> Cheers!
(Continue reading)

DAY,AARON GARTH | 3 Dec 2004 02:30
Favicon

Re: DBD::mysql not installing!! Help!!

Rick,

Your suggestion did the trick and everything went as planned.  Thank you
sooo much for the help.  I wish I would have emailed the group earlier.

Best wishes and Happy Holidays,
AGD

Quoting Rick Measham <rickm <at> 3d3.com>:

> You don't say what OS, but I'm going to guess it's RedHat 9?
>
> It's a Unicode problem that we had a lot with DateTime installations on
> RH9. To get it to work, prepend the recipe with a null language
> variable:
>
> LANG=; perl Makefile.PL
> make
> make test
> make install
>
> That will stop it trying to go all unicode on you, and the problems
> with
> the makefile will stop.
>
> If I've guessed wrong, then accept my appologies and let us know which
> distro you're using.
>
> Cheers!
> Rick Measham
(Continue reading)

Markus Linke | 5 Dec 2004 15:33
Picon

DBD::mysql Installation failes

Hi,

I recently installed Berkeley DB on my Linux box and upgraded mysql to
version 4.1.7.

I upgraded perl to the latest version and now I try to install
DBD::mysql. This fails :o((

The following error messages are shown when I try make Makefile.PL:

In file included from dbdimp.c:19:
dbdimp.h:21:49: mysql.h: No such file or directory
dbdimp.h:22:49: errmsg.h: No such file or directory
In file included from dbdimp.c:19:
dbdimp.h:106: parse error before "MYSQL"
dbdimp.h:106: warning: no semicolon at end of struct or union
dbdimp.h:117: parse error before '}' token
dbdimp.h:146: parse error before "MYSQL_RES"
dbdimp.h:146: warning: no semicolon at end of struct or union
dbdimp.h:159: parse error before '}' token
In file included from dbdimp.c:19:
dbdimp.h:195: parse error before '*' token
dbdimp.h:198: parse error before "MYSQL_RES"
dbdimp.h:202: parse error before '*' token
dbdimp.h:202: parse error before '*' token
dbdimp.h:203: warning: data definition has no type or storage class
dbdimp.c:122: parse error before '*' token
dbdimp.c: In function `ParseParam':
dbdimp.c:131: `slenPtr' undeclared (first use in this function)
dbdimp.c:131: (Each undeclared identifier is reported only once
(Continue reading)


Gmane