[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[ANN] amalgalite 0.2.0 Released

Jeremy Hinegardner

7/4/2008 9:41:00 PM

amalgalite version 0.2.0 has been released.

* http://www.copiousfreetime.org/articles/2008/07/04/amalgalite-0-2-0-rel...
* http://copiousfreetime.rubyforge.org/a...

Amalgalite embeds the SQLite database engine in a ruby extension. There is no
need to install SQLite separately. Look in the examples/ directory for examples
on:

* general usage
* blob io
* schema information

Also Scroll through Amalgalite::Database for a quick example, and a general
overview of the API.

{{ Release notes for Version 0.2.0 }}

* Major Enhancements
* blob support, both incremental access and normal access

* Minor Enhancements
* added examples/gem_db.rb script demonstrating taps and prepared statements
* added examples/schema-info.rb script demonstrating meta information
* added examples/blob.rb demonstrating incremental blob IO
* added acces to the SQLite3 errcode and errmsg api

* Bugfixes
* added taps.rb for requiring
* fixed prepared statement reset
* caught an error in executing prepared statements earlier in the process so
the correct error is reported


--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


5 Answers

unbewusst.sein

7/5/2008 10:23:00 AM

0

Jeremy Hinegardner <jeremy@hinegardner.org> wrote:

> Amalgalite embeds the SQLite database engine in a ruby extension.
> There is no need to install SQLite separately.
> Look in the examples/ directory for examples
> on:
>
> * general usage
> * blob io
> * schema information

i've tested your online example "gem-db.rb", looks good at insertion,
however get :
>>> gem-db.rb

Opening database (version 0.2.0)
Establishing taps
Create schema
Inserting 99 rows of gem information...
Took 0.246415 seconds
Done Inserting
NoMethodError: undefined method 'columns' for nil:NilClass
method is_column_rowid?
in statement.rb at line 349
method result_meta
in statement.rb at line 333
method times
in statement.rb at line 320
method result_meta
in statement.rb at line 320
method next_row
in statement.rb at line 250
method all_rows
in statement.rb at line 298
method execute
in database.rb at line 252
at top level
in gem-db.rb at line 72


line 72 being :
authors_by_number = db.execute("SELECT author, count( name ) as num_gems
FROM gems GROUP BY author ORDER BY num_gems DESC")


notice i'm now able to read the Firefox 3 bookmarks file
("places.sqlite") having "LONGVARCHAR" (wasn't OK with version 0.1).
--
Une Bévue

Jeremy Hinegardner

7/5/2008 6:46:00 PM

0

On Sat, Jul 05, 2008 at 07:21:44PM +0900, Une B?vue wrote:
> Jeremy Hinegardner <jeremy@hinegardner.org> wrote:
>
> > Amalgalite embeds the SQLite database engine in a ruby extension.
> > There is no need to install SQLite separately.
> > Look in the examples/ directory for examples
> > on:
> >
> > * general usage
> > * blob io
> > * schema information
>
> i've tested your online example "gem-db.rb", looks good at insertion,
> however get :
> >>> gem-db.rb
>
> Opening database (version 0.2.0)
> Establishing taps
> Create schema
> Inserting 99 rows of gem information...
> Took 0.246415 seconds
> Done Inserting
> NoMethodError: undefined method 'columns' for nil:NilClass
> method is_column_rowid?
> in statement.rb at line 349
> method result_meta
> in statement.rb at line 333
> method times
> in statement.rb at line 320
> method result_meta
> in statement.rb at line 320
> method next_row
> in statement.rb at line 250
> method all_rows
> in statement.rb at line 298
> method execute
> in database.rb at line 252
> at top level
> in gem-db.rb at line 72

This would be a bug in the example. I've run it so many times that the db
already existed all the time ran it. This is the patch:

@@ -37,6 +37,7 @@ unless schema.tables['gems']
author VARCHAR(128)
);
SQL
+ db.reload_schema!
end

#

Or download a new example script from github:

http://github.com/copiousfreetime/amalgalite/tree/master/examples...

> notice i'm now able to read the Firefox 3 bookmarks file
> ("places.sqlite") having "LONGVARCHAR" (wasn't OK with version 0.1).

I haven't done any testing with a Firefox 3 bookmarks file. I haven't done
anything specifically to address this, but I could see if SQLite internally had
decided that one of the values in there was to be stored as a BLOB storage type
that amalgalite would have failed before.

enjoy,

-jeremy

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


unbewusst.sein

7/6/2008 5:57:00 AM

0

Jeremy Hinegardner <jeremy@hinegardner.org> wrote:

> Or download a new example script from github:
>
> http://github.com/copiousfreetime/...
> /tree/master/examples/gem-db.rb

fine, thanks, it rocks !
>
> > notice i'm now able to read the Firefox 3 bookmarks file
> > ("places.sqlite") having "LONGVARCHAR" (wasn't OK with version 0.1).
>
> I haven't done any testing with a Firefox 3 bookmarks file. I haven't
> done anything specifically to address this, but I could see if SQLite
> internally had decided that one of the values in there was to be stored as
> a BLOB storage type that amalgalite would have failed before.

favicons are stored there as blob.

best,
--
Une Bévue

Jeremy Hinegardner

7/6/2008 6:23:00 AM

0

On Sun, Jul 06, 2008 at 02:56:40PM +0900, Une B?vue wrote:
> Jeremy Hinegardner <jeremy@hinegardner.org> wrote:
>
> > Or download a new example script from github:
> >
> > http://github.com/copiousfreetime/...
> > /tree/master/examples/gem-db.rb
>
> fine, thanks, it rocks !
> >
> > > notice i'm now able to read the Firefox 3 bookmarks file
> > > ("places.sqlite") having "LONGVARCHAR" (wasn't OK with version 0.1).
> >
> > I haven't done any testing with a Firefox 3 bookmarks file. I haven't
> > done anything specifically to address this, but I could see if SQLite
> > internally had decided that one of the values in there was to be stored as
> > a BLOB storage type that amalgalite would have failed before.
>
> favicons are stored there as blob.

Then yup, firefox 3 bookmarks file can be accessed via amalgalite now it look
like. That's very cool.

enjoy,

-jeremy

--
========================================================================
Jeremy Hinegardner jeremy@hinegardner.org


unbewusst.sein

7/6/2008 9:01:00 AM

0

Jeremy Hinegardner <jeremy@hinegardner.org> wrote:

> > favicons are stored there as blob.
>
> Then yup, firefox 3 bookmarks file can be accessed via amalgalite now it look
> like. That's very cool.

meta info about that :
Table: moz_favicons
==========================================
Column : expiration
|..........default_value :
|.....declared_data_type : LONG
|collation_sequence_name : BINARY
|....not_null_constraint : false
|............primary_key : false
|.........auto_increment : false

Column : url
|..........default_value :
|.....declared_data_type : LONGVARCHAR
|collation_sequence_name : BINARY
|....not_null_constraint : false
|............primary_key : false
|.........auto_increment : false

Column : mime_type
|..........default_value :
|.....declared_data_type : VARCHAR(32)
|collation_sequence_name : BINARY
|....not_null_constraint : false
|............primary_key : false
|.........auto_increment : false

Column : id
|..........default_value :
|.....declared_data_type : INTEGER
|collation_sequence_name : BINARY
|....not_null_constraint : false
|............primary_key : true
|.........auto_increment : false

Column : data
|..........default_value :
|.....declared_data_type : BLOB
|collation_sequence_name : BINARY
|....not_null_constraint : false
|............primary_key : false
|.........auto_increment : false

I'll try to extract those icons and build an html page with <img
src='data...' /> to learn with.

I get the first one, saved to file, using :
#! /usr/bin/env ruby

require 'rubygems'
require 'amalgalite'
require 'rexml/document'
require 'net/http'
require 'uri'

db=Amalgalite::Database.new( "places.sqlite" )
all_rows=db.execute( "SELECT url, mime_type, data FROM moz_favicons" )
blob_row = all_rows.first
puts blob_row['url']
puts blob_row['mime_type']
uri = URI.parse(blob_row['url'])
p "uri.host = #{uri.host}, uri.port = #{uri.port}, uri.scheme =
#{uri.scheme}, uri.path = #{uri.path}"
puts "#{uri.host}_#{File.basename(uri.path)}"
blob_row['data'].write_to_file( "#{uri.host}_#{File.basename(uri.path)}"
) if !blob_row['data'].nil?


works great !

now, i need that blob as a string to base64 encode it and make use of :

<img
src='data:#{blob_row['mime_type']};base64,#{Base64.b64encode(blob_row['d
ata'].to_string_io.read)}' />

for the time of posting i get no output from #to_string_io.read ?
--
Une Bévue