Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   [ANN] SQLite-Ruby 1.3.0 (http://www.velocityreviews.com/forums/t815565-ann-sqlite-ruby-1-3-0-a.html)

Jamis Buck 07-11-2004 09:00 PM

[ANN] SQLite-Ruby 1.3.0
 
Looks like there were no problems found in the SQLite-Ruby release
candidate (1.2.9.1)--or at least, no one reported any. ;) Thus, I'm
proud to announce the release of SQLite-Ruby 1.3.0.

SQLite-Ruby is a Ruby module for interfacing with SQLite
(http://www.sqlite.org) databases).

Version 1.3.0 does not add any new functionality beyond what already
existed in the release candidate (1.2.9.1). Thus, if you have 1.2.9.1
installed, there is no compelling reason to upgrade.

New features in 1.3.0 (and 1.2.9.1):

- The explicit dependency on 'arrayfields' was removed. Now, instead,
you can specify that rows be returned as arrays instead of hashes, and
then you can require 'arrayfields' explicitly to have the same behavior
as existed in 1.2.x.

- Exception classes now exist for all major error codes in the SQLite API.

- 'quote', 'decode', and 'encode' were added as class methods of
SQLite::Database. 'quote' will escape necessary characters in a string
(like a single quote). 'decode' and 'encode' are for safely serializing
and unserializing objects for storage in a SQLite database.

Enjoy! Feel free to submit feature requests if you feel the library is
lacking functionality you would find useful.

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."



Jamis Buck 07-12-2004 10:20 PM

Re: [ANN] SQLite-Ruby 1.3.0
 
Meino Christian Cramer wrote:
> From: Jamis Buck <jgb3@email.byu.edu>
> Subject: [ANN] SQLite-Ruby 1.3.0
> Date: Mon, 12 Jul 2004 06:00:23 +0900
>
> Hi,
>
> I tried to install with
>
> sudo ruby install.rb
>
> which works properly with previous versions (including 1.2.9.1)
> and got
>
> cp ext/extconf.rb ext/sqlite.c build
> cp -r lib build
> cd build
> checking for main() in -lsqlite... no
> checking for sqlite.h... no
> make: *** No targets specified and no makefile found. Stop.
> could not build sqlite module
>
> but ls /usr/lib/libsqlite* gives me:
>
> [sqlite-ruby-1.3.0/] :ls /usr/lib/libsqlite*
> /usr/lib/libsqlite-2.8.13.so.0 /usr/lib/libsqlite.so.0.8.6
> /usr/lib/libsqlite-2.8.13.so.0.8.6 /usr/lib/libsqlite3.la
> /usr/lib/libsqlite.la /usr/lib/libsqlite3.so
> /usr/lib/libsqlite.so /usr/lib/libsqlite3.so.0
> /usr/lib/libsqlite.so.0 /usr/lib/libsqlite3.so.0.8.6
>
> and ls /usr/include/sqlite*
>
> [sqlite-ruby-1.3.0/] :ls /usr/include/sqlite*
> /usr/include/sqlite.h /usr/include/sqlite3.h
>
> so it /seems/ that everything need is installed, but sqlite-ruby does
> not find it. What wnet wrong here ?


Interesting. Has anyone else had problems? Nothing changed in the setup
scripts between 1.2.9.1 and 1.3.0, so I'm surprised it doesn't work for
you now, when it used to. Could you send me the contents of the mkmf.log
file? (It should be in the 'build' subdirectory that gets created by the
install scripts.) That might help to troubleshoot this.

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."



Ara.T.Howard 07-13-2004 01:06 AM

Re: [ANN] SQLite-Ruby 1.3.0
 
On Tue, 13 Jul 2004, Jamis Buck wrote:

> Meino Christian Cramer wrote:
>> From: Jamis Buck <jgb3@email.byu.edu>
>> Subject: [ANN] SQLite-Ruby 1.3.0
>> Date: Mon, 12 Jul 2004 06:00:23 +0900
>>
>> Hi,
>>
>> I tried to install with
>>
>> sudo ruby install.rb
>>
>> which works properly with previous versions (including 1.2.9.1)
>> and got
>>
>> cp ext/extconf.rb ext/sqlite.c build
>> cp -r lib build
>> cd build
>> checking for main() in -lsqlite... no
>> checking for sqlite.h... no
>> make: *** No targets specified and no makefile found. Stop.
>> could not build sqlite module
>>
>> but ls /usr/lib/libsqlite* gives me:
>>
>> [sqlite-ruby-1.3.0/] :ls /usr/lib/libsqlite*
>> /usr/lib/libsqlite-2.8.13.so.0 /usr/lib/libsqlite.so.0.8.6
>> /usr/lib/libsqlite-2.8.13.so.0.8.6 /usr/lib/libsqlite3.la
>> /usr/lib/libsqlite.la /usr/lib/libsqlite3.so
>> /usr/lib/libsqlite.so /usr/lib/libsqlite3.so.0
>> /usr/lib/libsqlite.so.0 /usr/lib/libsqlite3.so.0.8.6
>>
>> and ls /usr/include/sqlite*
>>
>> [sqlite-ruby-1.3.0/] :ls /usr/include/sqlite*
>> /usr/include/sqlite.h /usr/include/sqlite3.h
>>
>> so it /seems/ that everything need is installed, but sqlite-ruby does
>> not find it. What wnet wrong here ?

>
> Interesting. Has anyone else had problems? Nothing changed in the setup
> scripts between 1.2.9.1 and 1.3.0, so I'm surprised it doesn't work for
> you now, when it used to. Could you send me the contents of the mkmf.log
> file? (It should be in the 'build' subdirectory that gets created by the
> install scripts.) That might help to troubleshoot this.


jamis-

i just installed with no problem using

Red Hat Enterprise Linux WS release 3 (Taroon Update 2)
Linux 2.4.21-15.0.3.ELsmp i686
ruby 1.8.1 (2003-12-25) [i686-linux]

and the --with-sqlite-dir=/full/path argument to install.rb

================================================== ===================

i have a (important i think) feature request:

first of all i love the new format (Arrays as tuples)! the only problem is
that if you want to use arrayfields (or some such) there doesn't seem to be an
easy way to get at the actual fields! in otherwords if you do this

require 'sqlite'
db = SQLite::Database.new 'db', 0
db.execute(schema = 'create table foo (bar)')
db.execute 'insert into foo values (42)'
tuples = db.execute 'select * from foo'
p tuples

you'll see

[["42"]]

how would you then set the fields? it'd be cool if the results were returned
exactly as the sqlite API returned them: that is, with the field names as the
first tuple, eg.

[["bar"], ["42"], etc...]

this would allow the following code:

require 'arrayfields'

fields, tuples = db.execute 'select * from foo'
tuples.fields = fields
tuple = tuples.first
p tuple['bar'] # => 42


i think the 'original' ruby sqlite module did exactly this and it was quite
nice. i especially like it when you do

fields, tuples = db.select 'count * from foo'
field = fields.first
tuple = tuples.first
p tuple[field]

since sqlite returns some whacky thing like 'count(*)' in these cases and i
can never remember if the dang field name is 'count (*)' or 'count( * )' etc.
this applies equally to the hash format: you never know the field name for
these types of queries. using fieldnames and arrayfields - you don't need to
remember, you know it's the first one.

on the other hand there may be as easy way to determine the fieldnames of the
last query and all this is superfluous - if so please enlighten.

i could dig into this tomorrow if you are taxed for time.

kind regards.

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
================================================== =============================

Ara.T.Howard 07-13-2004 02:16 AM

Re: [ANN] SQLite-Ruby 1.3.0
 
On Mon, 12 Jul 2004, Ara.T.Howard wrote:

> i have a (important i think) feature request:
>
> first of all i love the new format (Arrays as tuples)! the only problem is
> that if you want to use arrayfields (or some such) there doesn't seem to be
> an easy way to get at the actual fields!


never mind me - i just read the source and see that you've set '@fields' and
so only a 'require "arrayfields" is needed. i just got back from a week's
vacation so sorry for the confusion!

cheers.

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
================================================== =============================

Jamis Buck 07-13-2004 03:16 AM

Re: [ANN] SQLite-Ruby 1.3.0
 
Ara.T.Howard wrote:
> On Mon, 12 Jul 2004, Ara.T.Howard wrote:
>
>> i have a (important i think) feature request:
>>
>> first of all i love the new format (Arrays as tuples)! the only
>> problem is
>> that if you want to use arrayfields (or some such) there doesn't seem
>> to be
>> an easy way to get at the actual fields!

>
>
> never mind me - i just read the source and see that you've set '@fields'
> and
> so only a 'require "arrayfields" is needed. i just got back from a week's
> vacation so sorry for the confusion!


Glad you saw that. I need to take an hour or two and write up some
documentation, especially now that there are a few new features that
need describing.

For those that don't quite follow what Ara found, you can get at the
fields from an array by doing the following (even if you don't have
'arrayfields' installed):

results = db.execute "select * from some_table"
p results.first.fields

The 'fields' property will be an array listing the columns that were
selected, in the same order that they were returned. In other words, the
results.first.fields[i] will name the value at results.first[i].

If you have required the 'arrayfields' module, then results.first can be
treated (in some ways) as a hash, so you can give the name of a column
and have the corresponding value returned.

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."



Ara.T.Howard 07-13-2004 12:07 PM

Re: [ANN] SQLite-Ruby 1.3.0
 
On Tue, 13 Jul 2004, Meino Christian Cramer wrote:

> Two other things: Do you think it would be possible to have an install
> process which is separated from the configure/compile process for
> sqlite-ruby? I think it is a good idea to do as less as possible as root in
> general.


very true - LD_RUN_PATH, for instance, doesn't do the 'right thing' when used
as root.

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
================================================== =============================

Ara.T.Howard 07-13-2004 12:18 PM

rbconfig bug? - was (Re: [ANN] SQLite-Ruby 1.3.0)
 
On Tue, 13 Jul 2004, Meino Christian Cramer wrote:

> From: Meino Christian Cramer <Meino.Cramer@gmx.de>
> Subject: Re: [ANN] SQLite-Ruby 1.3.0
> Date: Tue, 13 Jul 2004 07:24:33 +0200 (CEST)
>
> Hi Jamis,
>
> an addition:
>
> After activating gcc-3.4.1 be hand, sqlite-ruby 1.3.0 does compile
> and install fine.
>


> So the remaining question is: What source of knowledge does the
> install process of sqlite-ruby use to figure out that there is a
> gcc-3.4.1 "somewhere in the deep of the system" installed and hidden
> from the world (ok,ok, I am definetly /NOT/ Shakespeare ;O))) and to
> choose the OPTIONS for that compiler but then call gcc-3.3.4 -- and
> fail.


run this to see all of ruby's configured values:

~ > ruby -r rbconfig -r yaml -e 'y Config::CONFIG'
---
abs_srcdir: "$(ac_abs_srcdir)"
sitedir: /home/ahoward/lib/ruby/site_ruby
MAKEFILES: Makefile
LIBRUBY: libruby-static.a
PACKAGE_VERSION: ''
prefix: /home/ahoward
COMMON_LIBS: ''
rubylibdir: /home/ahoward/lib/ruby/1.9
target: i686-pc-linux
<snip>


note that the compiler is noted:

~ > ruby -r rbconfig -r yaml -e 'y Config::CONFIG' | grep gcc
CC: gcc
LDSHARED: gcc -shared
CPP: gcc -E
ac_ct_CC: gcc
LIBRUBY_LDSHARED: gcc -shared


but not it's PATH! i'll bet if you do 'which gcc' you'll see it's gcc-3.3.4

if so, doing

~ > PATH=/full/path/to/correct/gcc:$PATH ruby intstall.rb --with-sqlite-dir=/full/path/to/any/non-standard/sqlite-install

might work


thus, if you compile ruby with one compiler certain flags are noted and these
flags are used when compiling extensions. the compiler by the NAME gcc is
used but if that gcc has changed....

perhaps rbconfig should contain the full path to the compiler and only use
that compiler?

-a


>
> Interesting...
>
> Two other things:
> Do you think it would be possible to have an install process which is
> separated from the configure/compile process for sqlite-ruby? I think
> it is a good idea to do as less as possible as root in general.
>
> When I searched for reasons of the gcc-mystique I encountered on my
> system :) I found that sqlite itsself can generate HTML-output.
> Is it possible to get such an output via sqlite-ruby?
>
> Ruby.use!
> Meino
>
>> From: Jamis Buck <jgb3@email.byu.edu>
>> Subject: Re: [ANN] SQLite-Ruby 1.3.0
>> Date: Tue, 13 Jul 2004 07:20:05 +0900
>>
>> Hi Jamis,
>>
>> thank you for your reply ! :)
>>
>> Things I have installed between 1.2.9.1 and 1.3.0
>>
>> Fox 1.2.6
>> scintilla 1.6.1
>> scite 1.6.1
>> fxscintilla 1.6.1
>> gem 0.7
>> fxruby 1.2.0
>>
>> May be, there is some "bad influence" ? ;)
>>
>> my mkmf.log:
>>
>> have_library: checking for main() in -lsqlite... -------------------- no
>>
>> "gcc -o conftest -I/home/mccramer/tmp/sqlite-ruby-1.3.0/build -I/usr/lib/ruby/1.8/i686-linux -O3 -mtune=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fforce-addr -falign-functions=4 -mpreferred-stack-boundary=2 -msse -m3dnow -mmmx -fPIC conftest.c -L"/usr/lib" -lruby-static -lsqlite -ldl -lcrypt -lm -lc"
>> cc1: error: invalid option `tune=athlon-xp'
>> checked program was:
>> /* begin */
>>
>> /*top*/
>> int main() { return 0; }
>> int t() { main(); return 0; }
>> /* end */
>>
>> "gcc -o conftest -I/home/mccramer/tmp/sqlite-ruby-1.3.0/build -I/usr/lib/ruby/1.8/i686-linux -O3 -mtune=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fforce-addr -falign-functions=4 -mpreferred-stack-boundary=2 -msse -m3dnow -mmmx -fPIC conftest.c -L"/usr/lib" -lruby-static -lsqlite -ldl -lcrypt -lm -lc"
>> cc1: error: invalid option `tune=athlon-xp'
>> checked program was:
>> /* begin */
>>
>>
>> /*top*/
>> int main() { return 0; }
>> int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
>> /* end */
>>
>> --------------------
>>
>> have_header: checking for sqlite.h... -------------------- no
>>
>> "gcc -E -I/home/mccramer/tmp/sqlite-ruby-1.3.0/build -I/usr/lib/ruby/1.8/i686-linux -O3 -mtune=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fforce-addr -falign-functions=4 -mpreferred-stack-boundary=2 -msse -m3dnow -mmmx -fPIC conftest.c -o conftest.i"
>> cc1: error: invalid option `tune=athlon-xp'
>> checked program was:
>> /* begin */
>> #include <sqlite.h>
>> /* end */
>>
>> --------------------
>>
>>
>> Now I see the source of bug: It is the "-mtune" option of gcc, which exits in
>> gcc's from version 3.4.x on. This was misinterpreted as "no sqlite installed".
>>
>> BUT: :O)
>>
>> I have installed gcc 3.3.4 (under /usr as normal) and I have a
>> hidden installation of gcc 3.4.1 (under /opt/gcc3.4.n/), which can
>> only be activated by preceeding PATH with the appropiate path to
>> gcc-3.4.1 /manually/ and switching the CFLAGS/CXXFLAGS /manually/.
>>
>> I had installed gcc-3.4.1 for experimenting.
>>
>> When I do a "echo $CFlAGS/$CXXFlAGS" as myself I get:
>>
>> [sqlite-ruby-1.3.0/] :echo $CFLAGS
>> -O3 -m3dnow -march=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fomit-frame-pointer -fforce-mem -fforce-addr -finline-functions -falign-functions=4 -mpreferred-stack-boundary=2
>> [sqlite-ruby-1.3.0/] :echo $CXXFLAGS
>> -O3 -m3dnow -march=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fomit-frame-pointer -fforce-mem -fforce-addr -finline-functions -falign-functions=4 -mpreferred-stack-boundary=2
>>
>> when I do a "sudo echo $CFlAGS/$CXXFlAGS", which would be equivalent
>> to "sudo ruby install.rb" I get
>>
>> [sqlite-ruby-1.3.0/] :sudo echo $CFLAGS
>> -O3 -m3dnow -march=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fomit-frame-pointer -fforce-mem -fforce-addr -finline-functions -falign-functions=4 -mpreferred-stack-boundary=2
>> [sqlite-ruby-1.3.0/] :sudo echo $CXXFLAGS
>> -O3 -m3dnow -march=athlon-xp -mcpu=athlon-xp -mfpmath=sse -funroll-loops -fomit-frame-pointer -fforce-mem -fforce-addr -finline-functions -falign-functions=4 -mpreferred-stack-boundary=2
>>
>> No "-mtune" option visible so far.
>>
>> I did a "grep -ril mtune" through the sqlite-ruby sources...nothing
>> (as you already know :)
>>
>> What is going on here. Does have SQlite-Ruby the seventh sense here ?
>> :)))
>>
>> Where does the "-mtune" came from ?
>>
>> Kind regards and thank you very much for your help in advance!
>> Meino

>
>
>


-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
================================================== =============================

nobu.nokada@softhome.net 07-13-2004 12:53 PM

Re: rbconfig bug? - was (Re: [ANN] SQLite-Ruby 1.3.0)
 
Hi,

At Tue, 13 Jul 2004 21:22:22 +0900,
Ara.T.Howard wrote in [ruby-talk:106194]:
> perhaps rbconfig should contain the full path to the compiler and only use
> that compiler?


$ ./configure CC=/full/path/to/gcc

--
Nobu Nakada



Ara.T.Howard 07-13-2004 02:41 PM

Re: rbconfig bug? - was (Re: [ANN] SQLite-Ruby 1.3.0)
 
On Tue, 13 Jul 2004 nobu.nokada@softhome.net wrote:

> Hi,
>
> At Tue, 13 Jul 2004 21:22:22 +0900,
> Ara.T.Howard wrote in [ruby-talk:106194]:
>> perhaps rbconfig should contain the full path to the compiler and only use
>> that compiler?

>
> $ ./configure CC=/full/path/to/gcc


good tip - thanks nobu.

-a
--
================================================== =============================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
================================================== =============================

Jamis Buck 07-13-2004 02:46 PM

Re: [ANN] SQLite-Ruby 1.3.0
 
Meino Christian Cramer wrote:
> Hi Jamis,
>
> an addition:
>
> After activating gcc-3.4.1 be hand, sqlite-ruby 1.3.0 does compile
> and install fine.
>
> So the remaining question is: What source of knowledge does the
> install process of sqlite-ruby use to figure out that there is a
> gcc-3.4.1 "somewhere in the deep of the system" installed and hidden
> from the world (ok,ok, I am definetly /NOT/ Shakespeare ;O))) and to
> choose the OPTIONS for that compiler but then call gcc-3.3.4 -- and
> fail.


Not being a gcc expert by any stretch of the imagination, I have no idea
why that would be occurring. I'm pretty sure it has nothing to do with
sqlite-ruby. (A way to test would be to try to compile other extension
libraries for Ruby.) Could it be the mkmf library? Or perhaps there is a
configuration file for gcc-3.4.1 that got installed in some global
location (like /etc, or pkgconfig, or something) which is messing things up?

> Two other things:
> Do you think it would be possible to have an install process which is
> separated from the configure/compile process for sqlite-ruby? I think
> it is a good idea to do as less as possible as root in general.


Well, I wanted to make it as painless as possible to install. You can
always go through the process manually:

1) cd to ext
2) run 'ruby extconf.rb'
3) run 'make'
4) as root, run 'make install'
5) cd to ../lib
6) as root, copy sqlite.rb to your site_ruby/1.8 directory

The reason for this setup is so that it all plays nicely with rubygems.
Perhaps 0.7 makes it easier, or perhaps I'm just advertising my
ignorance, but putting extconf.rb and sqlite.c in the root directory of
the project (which allows extconf.rb to acknowledge the existence of the
lib subdirectory) made it so that rubygems could not compile the
extension. Putting extconf.rb and sqlite.c in an 'ext' subdirectory,
which is what rubygems liked, made it so that extconf.rb did not know
that the 'lib' subdirectory existed. *sigh*

> When I searched for reasons of the gcc-mystique I encountered on my
> system :) I found that sqlite itsself can generate HTML-output.
> Is it possible to get such an output via sqlite-ruby?


Well, you can always generate the HTML yourself. :) The 'sqlite' command
line utility for SQLite does just that -- it uses the underlying SQLite
API to query the data, and then builds HTML output. If you want HTML
output using Ruby, you have to query the data and then format it yourself.

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck.org/jamis

"I use octal until I get to 8, and then I switch to decimal."




All times are GMT. The time now is 04:06 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.