Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

Dear Monks

I've been having issues with UNICODE since I started programming in Perl/Windows. Things work, but they mostly require so much adaptation, at least for me. Today I have a new problem I wasn't able to solve: connecting to a SQLite database saved in a directory containing unicode characters. The strange thing is (in my eyes): I am able to create the database without any problem, but I fail to open/access it. In the following (non-sense) script I create 2 databases in two directories (one with and one without unicode characters) and try to access them. Creation is okay for both. Access only for the database in the directory without unicode characters. What I am not understanding?

#!/usr/bin/perl use utf8; use strict; use warnings; use DBI; #first exmple without any unicode in directory my $PathCorpusDB1="a/databaseTest1.db"; print "Creating following database $PathCorpusDB1 ...\n"; my $dbh1 = DBI->connect("dbi:SQLite:$PathCorpusDB1", "", "", { RaiseEr +ror => 1, AutoCommit => 1, PrintError => 1 }); $dbh1->do( "CREATE TABLE data ( ID INTEGER PRIMARY KEY, text, filename +)" ); $dbh1->disconnect; print "Connecting to $PathCorpusDB1\n"; $dbh1 = DBI->connect("dbi:SQLite:$PathCorpusDB1", "", "", { RaiseError + => 1, AutoCommit => 1, PrintError => 1 }); my $AllDbText_ref1 = $dbh1->selectall_arrayref("SELECT filename FROM d +ata"); $dbh1->disconnect; #second example with unicode in directory my $PathCorpusDB2="ü/databaseTest2.db"; print "Creating following database $PathCorpusDB2 ...\n"; my $dbh2 = DBI->connect("dbi:SQLite:$PathCorpusDB2", "", "", { RaiseEr +ror => 1, AutoCommit => 1, PrintError => 1 }); $dbh2->do( "CREATE TABLE data ( ID INTEGER PRIMARY KEY, text, filename +)" ); $dbh2->disconnect; print "Connecting to $PathCorpusDB2\n"; $dbh2 = DBI->connect("dbi:SQLite:$PathCorpusDB2", "", "", { RaiseError + => 1, AutoCommit => 1, PrintError => 1 }); my $AllDbText_ref2 = $dbh2->selectall_arrayref("SELECT filename FROM d +ata"); $dbh2->disconnect;

This is the error message I get

D:\MyModule> perl .\UnicodeDatabaseConnect.pl Creating following database a/databaseTest1.db ... Connecting to a/databaseTest1.db Creating following database ³/databaseTest2.db ... Connecting to ³/databaseTest2.db DBI connect('³/databaseTest2.db','',...) failed: unable to open databa +se file at .\UnicodeDatabaseConnect.pl line 27.

In reply to Connect SQLite with unicode directory by IB2017

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-20 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found