Source: nntp.x.perl.org/rss/perl.macperl.anyperl.rdf
|
| perl.macperl.anyperl
...
| Re: [MacPerl-AnyPerl] DBI under the MAC by Sean Murphy |
Hi Keary <br/> Ouch, it was right in front of my nose and I didn't see it.
Thanks. On 10/12/2011, at 2:53 AM, Keary Suska wrote:
> On Dec 9, 2011, at 4:42 AM, Sean Murphy wrote: > >> my $sth2 = $dbh->prepare("insert into trans (accounts, transaction_date, description, amount, amount_type, transaction_type, serial, category_id) values (?, ?, ?, ?, ?, ?, ?, ?);") >> or die("Cannot prepare: " . DBI::errstr() ); >> >> >> When the above is executed in the full script. We get the following error: >> >> DBD::SQLite::db prepare failed: table trans has no column named accounts at ./insert_budget.pl line 60. >> Cannot prepare: table trans has no column named accounts at ./insert_budget.pl line 60. > > "accounts" (plural) > >> sqlite> .schema trans >> CREATE TABLE trans (transaction_id int primary key, account int, transaction_date date, description varchar(80), amount decimal (11,2), amount_type varchar(3) not null, transaction_type varchar(40), serial varchar(40), category_id int); > > "account" (singular) > > HTH, > > Keary Suska
| Re: [MacPerl-AnyPerl] Re: macperl-anyperl Digest 9 Dec 20... |
Hi Joel
Thanks for the heads up. The description of the list didn't indicate it was for the PowerPC version of Perl.
I will move to the other list you indicated.
Cheers Sean On 09/12/2011, at 11:26 PM, Joel Rees wrote:
> Joel
| Re: [MacPerl-AnyPerl] DBI under the MAC by Keary Suska |
On Dec 9, 2011, at 4:42 AM, Sean Murphy wrote:
> my $sth2 = $dbh->prepare("insert into trans (accounts, transaction_date, description, amount, amount_type, transaction_type, serial, category_id) values (?, ?, ?, ?, ?, ?, ?, ?);") > or die("Cannot prepare: " . DBI::errstr() ); > > > When the above is executed in the full script. We get the following error: > > DBD::SQLite::db prepare failed: table trans has no column named accounts at ./insert_budget.pl line 60. > Cannot prepare: table trans has no column named accounts at ./insert_budget.pl line 60.<br/> "accounts" (plural)
> sqlite> .schema trans > CREATE TABLE trans (transaction_id int primary key, account int, transaction_date date, description varchar(80), amount decimal (11,2), amount_type varchar(3) not null, transaction_type varchar(40), serial varchar(40), category_id int);
"account" (singular)
HTH,
Keary Suska
| Re: macperl-anyperl Digest 9 Dec 2011 11:43:02 -0000 Issu... |
> > From: Sean Murphy <mhysnm1964@gmail.com> > Date: 平成23年12月9日 20:42:49:JST > To: macperl-anyperl@perl.org > Subject: DBI under the MAC > > > Hi All. > > I am having some strange behaviours. I have created a simple script > to insert data into a SQLite database. When I use the prepare are > statement. The DBI driver complains that there is no such table. > > The code looks like thus: > > #!/usr/bin/perl > > # Combining credit and savings sheets > # to find expenses and income. > > > use strict; > use DBI; > > my $db_driver = "SQLite"; > my $db_file = "budget.db"; > my $dns = "DBI:$db_driver:database=$db_file"; > > my $dbh = DBI->connect ($dns, '', '', > { RaiseError => 1, AutoCommit => 0}); > > my $sth1 = $dbh->prepare("insert into cat (name) values (?);") > or die("Cannot prepare table: " . DBI::errstr() ); > > my $sth2 = $dbh->prepare("insert into trans (accounts, > transaction_date, description, amount, amount_type, > transaction_type, serial, category_id) values > (?, ?, ?, ?, ?, ?, ?, ?);") > or die("Cannot prepare: " . DBI::errstr() ); > > > When the above is executed in the full script. We get the following > error: > > DBD::SQLite::db prepare failed: table trans has no column named > accounts at ./insert_budget.pl line 60. > Cannot prepare: table trans has no column named accounts at ./ > insert_budget.pl line 60. > > The Schema for the table shows trans being present. As follows: > > sqlite> .schema trans > CREATE TABLE trans (transaction_id int primary key, account int, > transaction_date date, description varchar(80), amount decimal > (11,2), amount_type varchar(3) not null, transaction_type varchar > (40), serial varchar(40), category_id int); > sqlite> > > Any ideas what might be going on here? The drivers are being found. > I have tested this by using the perl -d option with the script. > > Sean
From the content of your question, I'm guessing that you're working with Mac OS X and therefore non-MacPerl perl.
This list is for MacPerl, which is perl on the old pre-Mac OS X Mac systems.
The list you probably want is at macosx@perl.org .
I really shouldn't forward this to that list, but I will.
As far as your question is concerned, I'm not familiar with SQLite, but it looks to me like your problem is not Mac OS X related. You might want to check your table definition again.
Joel Rees (waiting for a 3+GHz ARM processor to come out, to test Tim's willingness to switch again.)
| DBI under the MAC by Sean Murphy |
Hi All.
I am having some strange behaviours. I have created a simple script to insert data into a SQLite database. When I use the prepare are statement. The DBI driver complains that there is no such table.
The code looks like thus:
#!/usr/bin/perl
# Combining credit and savings sheets # to find expenses and income.
use strict; use DBI; my $db_driver = "SQLite"; my $db_file = "budget.db"; my $dns = "DBI:$db_driver:database=$db_file";
my $dbh = DBI->connect ($dns, '', '', { RaiseError => 1, AutoCommit => 0});
my $sth1 = $dbh->prepare("insert into cat (name) values (?);") or die("Cannot prepare table: " . DBI::errstr() );
my $sth2 = $dbh->prepare("insert into trans (accounts, transaction_date, description, amount, amount_type, transaction_type, serial, category_id) values (?, ?, ?, ?, ?, ?, ?, ?);") or die("Cannot prepare: " . DBI::errstr() );
When the above is executed in the full script. We get the following error:
DBD::SQLite::db prepare failed: table trans has no column named accounts at ./insert_budget.pl line 60. Cannot prepare: table trans has no column named accounts at ./insert_budget.pl line 60.
The Schema for the table shows trans being present. As follows:
sqlite> .schema trans CREATE TABLE trans (transaction_id int primary key, account int, transaction_date date, description varchar(80), amount decimal (11,2), amount_type varchar(3) not null, transaction_type varchar(40), serial varchar(40), category_id int); sqlite>
Any ideas what might be going on here? The drivers are being found. I have tested this by using the perl -d option with the script.
Sean
| Re: [MacPerl-AnyPerl] Let perl replase words by Jeff Lowrey |
$head =~ s/($replace)/<u>$1<\/u>/gi;
| Re: Let perl replase words by Chris Sarnowski |
On Oct 7, 2006, at 2:59 PM, Eelco Alosery wrote:
> > Hello, > > I have a small, (maby big) problem. > > Im writing a search script for my site, and wand to do some > replacing of words. > > I have a string that contains for example this : > Test this is a smal test script line. > > Now i have a search patern : > test > > What i want to do is this. > Test and test must be replased by <b>Test</b> and <b>test</b> > > Thus al (case insensative) matches to test must be converted to > bold words. > > I have tested a lot, and the best result sovar is this code : > $head =~ s/$replace/<u>$replace<\/u>/gi; > > But this code replases Test to <b>test</b> it is realy convertet to > the original search patern. > > Any help whit this is very welcome. > > Thanks, > Eelco Alosery
$head =~ s/($replace)/<u>$1<\/u>/gi;
This will match the value of $replace regardless of case. But $1 will preserve the case of the matched string, so will do what you want.
Just for fun, here is a program with a function that will replace any <br/>string with a different string and will match the case of each character of the original string in the corresponding position of the replacement string.
---- begin testcase.pl ---- #!/usr/bin/perl -w
use strict; sub preserve_case($$) { my ($from, $to) = @_; my ($lf, $lt) = map length, @_; if ($lt < $lf) { $from = substr $from, 0, $lt; } else { $from .= substr $to, $lf; } return uc $to | ($from ^ uc $from); }
### begin main
my $string = shift; my $orig = shift; my $replace = shift; $string =~ s/($orig)/preserve_case($1, $replace)/egi; print $string, "\n";
---- end testcase.pl ----
% testcase.pl "here is a foo string with a proper Foo and a FoO" foo bar here is a bar string with a proper Bar and a BaR
| Let perl replase words by Eelco Alosery |
Hello,
I have a small, (maby big) problem.
Im writing a search script for my site, and wand to do some replacing of words.
I have a string that contains for example this : Test this is a smal test script line.
Now i have a search patern : test
What i want to do is this.<br/>Test and test must be replased by <b>Test</b> and <b>test</b>
Thus al (case insensative) matches to test must be converted to bold words.
I have tested a lot, and the best result sovar is this code : $head =~ s/$replace/<u>$replace<\/u>/gi;
But this code replases Test to <b>test</b> it is realy convertet to the original search patern.
Any help whit this is very welcome.
Thanks, Eelco Alosery
| Install MacPerl on Freebsd by Joel Rees |
> I am try to write a script that will rename Macintosh files to windows > file > name format. I do not have access to a Macintosh computer. Can > MacPerl, > Mac::Files, and Mac::MoreFiles run on a FreeBSD system?
If it's just a matter of naming, you don't need Mac::Files and the like.<br/> But I would guess what you want to do is actually use the file type info that would be available in the Mac HFS file system to determine the file extensions? There used to be packages available for that sort of thing, but I'm not sure if you can still find them. They never worked perfectly, as I recall. But it wouldn't be perl, it would be *nix. The utilities for installing netBSD or openBSD on the old Macs came with some utilities for moving only one fork into a BSD partition, but those are not scriptable by any means.
Hard to say what to suggest without more information. Old Macs with built-in ethernet and scsi are often really cheap on ebay, for instance. Likely to be easier to run the MacBSD on a Mac and have it ship things up the wire or save things onto a MS-DOS SCSI volume, or, if the files aren't big, onto an MS-DOS floppy.
-- Joel Rees even though much of what I do is not sensible it does make sense if you know why ...
| Re: [MacPerl-AnyPerl] Install MacPerl on Freebsd by Bart ... |
On Thu, 27 Jan 2005 15:43:36 -0700, Aaron Siegel wrote:
>I would like the ability to extract the creator and file type from the file so >I can automate the renaming of Macintosh filenames to Windows filenames. >MacPerl::GetFileInfo
If you have access to some Mac, you could convert the files to MacBinary, extension .bin. That makes it a flat file, and creator/file type are part of the header. There are some ancient, Mac Classic, conversion utilities floating around.
Or, you could go frisky and go take a peek to what's in the hidden ".AppleDouble" subfolder, if that's indeed what your file system uses.
-- Bart.
Newsfeed display by CaRP |
|
|