|
From: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= on 5 Jul 2008 06:22 Jeremy Hinegardner <jeremy(a)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
From: Jeremy Hinegardner on 5 Jul 2008 14:46 On Sat, Jul 05, 2008 at 07:21:44PM +0900, Une B?vue wrote: > Jeremy Hinegardner <jeremy(a)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/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 -- ======================================================================== Jeremy Hinegardner jeremy(a)hinegardner.org
From: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= on 6 Jul 2008 01:56 Jeremy Hinegardner <jeremy(a)hinegardner.org> wrote: > Or download a new example script from github: > > http://github.com/copiousfreetime/amalgalite > /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
From: Jeremy Hinegardner on 6 Jul 2008 02:23 On Sun, Jul 06, 2008 at 02:56:40PM +0900, Une B?vue wrote: > Jeremy Hinegardner <jeremy(a)hinegardner.org> wrote: > > > Or download a new example script from github: > > > > http://github.com/copiousfreetime/amalgalite > > /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(a)hinegardner.org
From: =?ISO-8859-1?Q?Une_B=E9v?==?ISO-8859-1?Q?ue?= on 6 Jul 2008 05:01 Jeremy Hinegardner <jeremy(a)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
|
Pages: 1 Prev: sqlite3 Re: title avoiding spurious response Next: Open a remote file and edit it |