[ANN] SQLite-Ruby 1.2.0

J

Jamis Buck

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

http://rubyforge.org/projects/sqlite-ruby

This release adds support for Ara Howard's "arrayfields" module. If that
module is installed, each row of a result set will be returned as an
Array, instead of a Hash. SQLite-Ruby will function without arrayfields,
however, in which case each row is returned as a Hash (as before).

The most significant change in this release is that columns in result
sets are numbered starting at 0, instead of 1. This may cause existing
SQLite-Ruby programs to fail if you upgrade, so proceed with caution!
Caveat emptor!

Other minor changes: the install script has been modified so that any
parameters you give to it are passed through to the extconf.rb script.
This allows you to (for instance) specify a custom location for the
sqlite libraries and header files. (Thanks, Ara and Ludo!)

As before, this is available as a gem, so you can just type "gem -i
sqlite" and have it installed for you. Additionally, you can use "gem
--gen-rdoc --run-tests -i sqlite" to generate the documentation and run
the test suite at the same time.

For those that are "gem-challenged", the library is available in bz2,
gz, and zip format as well. :)

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'
 
A

Ara.T.Howard

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

http://rubyforge.org/projects/sqlite-ruby

This release adds support for Ara Howard's "arrayfields" module. If that
module is installed, each row of a result set will be returned as an
Array, instead of a Hash. SQLite-Ruby will function without arrayfields,
however, in which case each row is returned as a Hash (as before).

The most significant change in this release is that columns in result
sets are numbered starting at 0, instead of 1. This may cause existing
SQLite-Ruby programs to fail if you upgrade, so proceed with caution!
Caveat emptor!

Other minor changes: the install script has been modified so that any
parameters you give to it are passed through to the extconf.rb script.
This allows you to (for instance) specify a custom location for the
sqlite libraries and header files. (Thanks, Ara and Ludo!)

As before, this is available as a gem, so you can just type "gem -i
sqlite" and have it installed for you. Additionally, you can use "gem
--gen-rdoc --run-tests -i sqlite" to generate the documentation and run
the test suite at the same time.

For those that are "gem-challenged", the library is available in bz2,
gz, and zip format as well. :)

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'


awesome! thanks alot jamis! stay tuned for my clustering software based on
your sqlite project - ruby queue (rq).

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
===============================================================================
 
A

Ara.T.Howard

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

http://rubyforge.org/projects/sqlite-ruby

This release adds support for Ara Howard's "arrayfields" module. If that
module is installed, each row of a result set will be returned as an
Array, instead of a Hash. SQLite-Ruby will function without arrayfields,
however, in which case each row is returned as a Hash (as before).

The most significant change in this release is that columns in result
sets are numbered starting at 0, instead of 1. This may cause existing
SQLite-Ruby programs to fail if you upgrade, so proceed with caution!
Caveat emptor!

Other minor changes: the install script has been modified so that any
parameters you give to it are passed through to the extconf.rb script.
This allows you to (for instance) specify a custom location for the
sqlite libraries and header files. (Thanks, Ara and Ludo!)

As before, this is available as a gem, so you can just type "gem -i
sqlite" and have it installed for you. Additionally, you can use "gem
--gen-rdoc --run-tests -i sqlite" to generate the documentation and run
the test suite at the same time.

For those that are "gem-challenged", the library is available in bz2,
gz, and zip format as well. :)

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'

jamis-

anyway to force hash usage even if arrayfields is installed? i want to do a
speed comparison...

-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
===============================================================================
 
J

Jamis Buck

Ara.T.Howard said:
jamis-

anyway to force hash usage even if arrayfields is installed? i want to
do a
speed comparison...

Yup. Just do

db.use_arrayfields = false

Where 'db' is your open database instance.

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'
 
A

Ara.T.Howard

Yup. Just do

db.use_arrayfields = false

Where 'db' is your open database instance.

very cool. my tests show about 2/3 the memusage by using arrayfields on a
table with 50000 rows. the access is slower since there are two method calls
instead of one, of course, but it's not significant. and of course code like
this:

tuples.each do |t|
puts t.join(',')
end

is much faster since otherwise you'd be doing something like:

ikeys = tuples.first.keys.select{|k| Numeric === k}.sort

tuples.each do |t|
puts(t.values_at(*ikeys).join(','))
end

which invloves an extra object creation, array explosion, and method call per
tuple.

if i re-wrote arrayfields in C it'd probably be better/same for all aspects
including lookup speed...

thanks for effort and quick turn-around jamis!

-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
===============================================================================
 
R

Reimer Behrends

Jamis Buck ([email protected]) wrote:
[...]
Yup. Just do

db.use_arrayfields = false

Shouldn't that be off by default? I don't like the idea of the SQLite
interface suddenly breaking just because somebody is using arrayfields
somewhere else in an application.

Reimer Behrends
 
J

Jamis Buck

Reimer said:
Jamis Buck ([email protected]) wrote:
[...]
Yup. Just do

db.use_arrayfields = false


Shouldn't that be off by default? I don't like the idea of the SQLite
interface suddenly breaking just because somebody is using arrayfields
somewhere else in an application.

Reimer Behrends

.

Using arrayfields will not break your application. In fact, from a
client's perspective, really can't tell which is being used, unless you
actually ask what the type of the row object is.

Well, I take that back. If you are using some method of Hash on the row
object (like "keys" or "values"), your code will break...

I don't mind making the use of arrayfields false by default. Anyone else
have a strong opinion?

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'
 
A

Ara.T.Howard

Using arrayfields will not break your application. In fact, from a
client's perspective, really can't tell which is being used, unless you
actually ask what the type of the row object is.

Well, I take that back. If you are using some method of Hash on the row
object (like "keys" or "values"), your code will break...

funny you should mention that - i can't see any reason why ArrayFields
shouldn't have

def keys
fields
end
def values
self
end

an it would __really__ behave in a hashlike fashion... thoughts?

I don't mind making the use of arrayfields false by default. Anyone else
have a strong opinion?

i think off is good for reasons metioned by OP. i am really liking the new
interface - i just updated my code, which consisted of removing about 100
lines AND it runs faster - nice.


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
===============================================================================
 
S

Sean O'Dell

Reimer said:
Jamis Buck ([email protected]) wrote:
[...]
Yup. Just do

db.use_arrayfields = false

Shouldn't that be off by default? I don't like the idea of the SQLite
interface suddenly breaking just because somebody is using arrayfields
somewhere else in an application.

Reimer Behrends

.

Using arrayfields will not break your application. In fact, from a
client's perspective, really can't tell which is being used, unless you
actually ask what the type of the row object is.

Well, I take that back. If you are using some method of Hash on the row
object (like "keys" or "values"), your code will break...

I don't mind making the use of arrayfields false by default. Anyone else
have a strong opinion?

Personally, what I would do is simply provide an array that arrayfields is
happy with as a fields descriptor, and provide your rows as plain arrays,
also something arrayfields is happy with. Use arrayfields in your
documentation examples, but don't actually depend on its existence, just
provide the arrays and let the developers decide whether to use arrayfields
or rows as plain arrays.

Sean O'Dell
 
K

Kirk Haines

On Fri, 2 Jul 2004 05:52:49 +0900, Ara.T.Howard wrote
funny you should mention that - i can't see any reason why
ArrayFields shouldn't have

def keys
fields
end
def values
self
end

an it would __really__ behave in a hashlike fashion... thoughts?

I was going to suggest that the hash methods be added. I don't see a
downside to doing that.


Kirk
 
A

Ara.T.Howard

I was going to suggest that the hash methods be added. I don't see a
downside to doing that.

some of them are out, like each, since the impl for Array and Hash are
different, but some methods like

#fetch
#keys
#values

would be a nice ducktype facet. i'll look into this for the next release
which, i hope, will include a C impl as well.

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
===============================================================================
 
S

Sean O'Dell

some of them are out, like each, since the impl for Array and Hash are
different, but some methods like

Isn't it a unique object now? For some reason, I thought you made ArrayFields
its own class. If you did that, you could add each because ArrayFields is a
hash interface to arrays; it's hash-like.

Sean O'Dell
 
W

William Pinelo Marin

could anyone help me to make sqlite 1.2.0 ?

----------------------8<----------------------------------------------------
-
D:\temp\sqlite-ruby-1.2.0>ver
Microsoft Windows 2000 [Version 5.00.2195]

D:\temp\sqlite-ruby-1.2.0>ruby -v
ruby 1.8.2 (2004-06-04) [i386-mswin32]

D:\temp\sqlite-ruby-1.2.0>cl
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

D:\temp\sqlite-ruby-1.2.0>ruby install.rb
cp ext/extconf.rb ext/sqlite.c build
cp -r lib build
cd build
checking for main() in sqlite.lib... no
checking for sqlite.h... yes
checking for sqlite_open() in sqlite.lib... no
make: *** No targets specified and no makefile found. Stop.
could not build sqlite module

D:\temp\sqlite-ruby-1.2.0\build>type mkmf.log
have_library: checking for main() in sqlite.lib... -------------------- no

"cl -nologo -Feconftest -ID:/temp/sqlite-ruby-1.2.0/build -Id:/ruby/lib/ruby
/1.8/i386-mswin32 -I. -I./.. -I./../missing -MD -Zi -O2b
2xg- -G5 conftest.c msvcrt-ruby18-static.lib sqlite.lib oldnames.lib
user32.lib advapi32.lib wsock32.lib -link -libpath:"d:/
ruby/lib" -stack:0x2000000"
conftest.c
LINK : fatal error LNK1104: cannot open file "sqlite.lib"
checked program was:
/* begin */

/*top*/
int main() { return 0; }
int t() { main(); return 0; }
/* end */

"cl -nologo -Feconftest -ID:/temp/sqlite-ruby-1.2.0/build -Id:/ruby/lib/ruby
/1.8/i386-mswin32 -I. -I./.. -I./../missing -MD -Zi -O2b
2xg- -G5 conftest.c msvcrt-ruby18-static.lib sqlite.lib oldnames.lib
user32.lib advapi32.lib wsock32.lib -link -libpath:"d:/
ruby/lib" -stack:0x2000000"
conftest.c
LINK : fatal error LNK1104: cannot open file "sqlite.lib"
checked program was:
/* begin */
#include <winsock2.h>
#include <windows.h>

/*top*/
int main() { return 0; }
int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
/* end */

--------------------

have_header: checking for sqlite.h... -------------------- yes

"cl -ID:/temp/sqlite-ruby-1.2.0/build -Id:/ruby/lib/ruby/1.8/i386-mswin32 -I
-I./.. -I./../missing -MD -Zi -O2b2xg- -G5 conftest.c
-P"
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

conftest.c
checked program was:
/* begin */
#include <sqlite.h>
/* end */

--------------------

have_library: checking for sqlite_open() in
sqlite.lib... -------------------- no

"cl -nologo -Feconftest -ID:/temp/sqlite-ruby-1.2.0/build -Id:/ruby/lib/ruby
/1.8/i386-mswin32 -I. -I./.. -I./../missing -MD -Zi -O2b
2xg- -G5 conftest.c msvcrt-ruby18-static.lib sqlite.lib oldnames.lib
user32.lib advapi32.lib wsock32.lib -link -libpath:"d:/
ruby/lib" -stack:0x2000000"
conftest.c
LINK : fatal error LNK1104: cannot open file "sqlite.lib"
checked program was:
/* begin */

/*top*/
int main() { return 0; }
int t() { sqlite_open(); return 0; }
/* end */

"cl -nologo -Feconftest -ID:/temp/sqlite-ruby-1.2.0/build -Id:/ruby/lib/ruby
/1.8/i386-mswin32 -I. -I./.. -I./../missing -MD -Zi -O2b
2xg- -G5 conftest.c msvcrt-ruby18-static.lib sqlite.lib oldnames.lib
user32.lib advapi32.lib wsock32.lib -link -libpath:"d:/
ruby/lib" -stack:0x2000000"
conftest.c
conftest.c(6) : error C2065: 'sqlite_open' : undeclared identifier
checked program was:
/* begin */
#include <winsock2.h>
#include <windows.h>

/*top*/
int main() { return 0; }
int t() { void ((*volatile p)()); p = (void ((*)()))sqlite_open; return 0; }
/* end */

--------------------

D:\temp\sqlite-ruby-1.2.0\build>
----------------------8<----------------------------------------------------
-


thanks,

--.Pinelo.

----- Original Message -----
From: "Jamis Buck" <[email protected]>
To: "ruby-talk ML" <[email protected]>
Sent: Thursday, July 01, 2004 11:56 AM
Subject: [ANN] SQLite-Ruby 1.2.0

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

http://rubyforge.org/projects/sqlite-ruby

This release adds support for Ara Howard's "arrayfields" module. If that
module is installed, each row of a result set will be returned as an
Array, instead of a Hash. SQLite-Ruby will function without arrayfields,
however, in which case each row is returned as a Hash (as before).

The most significant change in this release is that columns in result
sets are numbered starting at 0, instead of 1. This may cause existing
SQLite-Ruby programs to fail if you upgrade, so proceed with caution!
Caveat emptor!

Other minor changes: the install script has been modified so that any
parameters you give to it are passed through to the extconf.rb script.
This allows you to (for instance) specify a custom location for the
sqlite libraries and header files. (Thanks, Ara and Ludo!)

As before, this is available as a gem, so you can just type "gem -i
sqlite" and have it installed for you. Additionally, you can use "gem
--gen-rdoc --run-tests -i sqlite" to generate the documentation and run
the test suite at the same time.

For those that are "gem-challenged", the library is available in bz2,
gz, and zip format as well. :)

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2) [0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/
/).map{|n|n.to_i(16).chr}.join))'
 
A

Ara.T.Howard

Isn't it a unique object now? For some reason, I thought you made ArrayFields
its own class. If you did that, you could add each because ArrayFields is a
hash interface to arrays; it's hash-like.

Sean O'Dell

ArrayFields is a Module used to extend only those Array instances that use the
#fields= method. the Array class itself is never modified.

FieldedArray is a class which wraps an array and which also includes
ArrayFields. by defining method_missing to use it's wrapped array it can
leveage the ArrayFields module w/o extend the actual array object.

summary:

- class Array never has anything added to it other than #fields=

- if, and only if, #fields= is called then that instance will auto-extend
it's singleton class to have the methods of ArrayFields

- FieldedArray behaves just like an Array whose singleton class has been
extended, but w/o actually extending it. this is accompished by both
extending the FieldedArray object with ArrayFields AND delgating missing
methods (in this case all the calls to super in ArrayFields) to this
array.

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
===============================================================================
 
R

Relm

some of them are out, like each, since the impl for Array and Hash are
different, but some methods like

#fetch
#keys
#values

would be a nice ducktype facet. i'll look into this for the next release
which, i hope, will include a C impl as well.

How about checking the arity of the block given to #each:

row.each {|x| } # Array
row.each {|k,v| } # Hash

Adding #each_pair would work nicely also.
 
J

Jamis Buck

William said:
could anyone help me to make sqlite 1.2.0 ?
[snip]

Well, I no expert on building Ruby modules for Windows, but it looks
like it can't find the library for SQLite. You can tell the build system
where to look for that file, with the --with-sqlite-lib option. Just do
something like:

ruby install.rb --with-sqlite-lib=c:\directory\containing\sqlite\lib

See if that works for you. Good luck! Let me know if you get it working.

--
Jamis Buck
(e-mail address removed)
http://www.jamisbuck.org/jamis

ruby -ropenssl
-e'k="01234567";p((c,c.padding,c.iv,c.key=OpenSSL::Cipher::BF.new,0,k,k*2)[0].decrypt.update("1A81803C452C324619D319F980D5B84DBB45FC0FE2BAA045".scan(/../).map{|n|n.to_i(16).chr}.join))'
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top