[ANN] amalgalite 0.2.0 Released

  • Thread starter Jeremy Hinegardner
  • Start date
J

Jeremy Hinegardner

amalgalite version 0.2.0 has been released.

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

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
 
U

Une Bévue

Jeremy Hinegardner said:
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 :
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).
 
J

Jeremy Hinegardner

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

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/gem-db.rb
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
 
U

Une Bévue

Jeremy Hinegardner said:
Or download a new example script from github:

http://github.com/copiousfreetime/amalgalite
/tree/master/examples/gem-db.rb

fine, thanks, it rocks !
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,
 
J

Jeremy Hinegardner

fine, thanks, it rocks !

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
 
U

Une Bévue

Jeremy Hinegardner said:
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 ?
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top