sqlite3-ruby

Rails 3.1 app can't install sqlite3 gem because libraries are out of date

雨燕双飞 提交于 2020-01-02 20:03:36
问题 The latest SQLite3 library available on CentOS 5.6 and which is installed is version 3.3.6. It's my understanding that the sqlite3 gem needs version 3.6 or higher. How do I get my app to work with SQLite3 without upgrading the library on my server? It's in a work environment and I'm simply not allowed to upgrade it. 回答1: You could compile a static library of the version of sqlite you require. Then install the sqlite3 gem with a reference to your new static library. While I haven't tested this

Rails 3.1 app can't install sqlite3 gem because libraries are out of date

旧街凉风 提交于 2020-01-02 20:00:54
问题 The latest SQLite3 library available on CentOS 5.6 and which is installed is version 3.3.6. It's my understanding that the sqlite3 gem needs version 3.6 or higher. How do I get my app to work with SQLite3 without upgrading the library on my server? It's in a work environment and I'm simply not allowed to upgrade it. 回答1: You could compile a static library of the version of sqlite you require. Then install the sqlite3 gem with a reference to your new static library. While I haven't tested this

Rails rake db:seed Inserts nulls instead of values

♀尐吖头ヾ 提交于 2019-12-25 12:41:09
问题 I'm using Ruby 2.1.5 and Rails 4.2.1 I'm trying to put some static database entries into a sqlite3 table via seeds.rb. When I run rake db:seed, I get the correct number of rows inserted with appropriate timestamp columns, but the actual data column, name, is not being populated. Name is being printed out inside the loop. db/seed.rb for g in ['Harmony', 'Melody', 'Technique', 'Soloing'] Group.create(name: g) put(g) end app/models/group.rb: class Group < ActiveRecord::Base attr_accessor :name

Uninitialized constant Encoding with sqlite3-ruby on windows

╄→尐↘猪︶ㄣ 提交于 2019-12-20 20:27:42
问题 On a new machine, installed ruby with the 1-click installer for windows. Installed rails 2.3.2 and all associated gems, then I installed the sqlite3 binaries (into the c:\ruby\bin folder). Lastly I did gem install sqlite3-ruby -v=1.2.3 (which is apparently the latest version that works with windows) This error happens when I run rake db:migrate or when any ActiveRecord object is touched at runtime. The error looks like this: ** Invoke db:migrate (first_time) ** Invoke environment (first_time)

Simple SQL Lite table/import question

北战南征 提交于 2019-12-18 01:05:12
问题 I have a simple SQL question. I want to make a 3 column database and I have the following code: sqlite3 meshdb.db "create table t1 (t1key INTEGER PRIMARY KEY, prideID, pubmedID);" When I try to import a simple csv file with two columns (prideID and pubmedID), I get a "expected 3 columns of data but found 2" error. I want the t1key to be an integer, and automatically count up as new fields are added. Do I have to put NOT NULL in front of PRIMARY KEY to for this to work? 回答1: .import does not

Is there are reason I select by a string columns which contains SHA1 hexdigests?

久未见 提交于 2019-12-13 14:18:21
问题 I have an invitations table which looks like this sqlite> .schema invitations CREATE TABLE "invitations" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "sender_id" integer , "recipient_email" varchar(255) , "token" varchar(255) , "sent_at" datetime , "team_id" integer , "created_at" datetime , "updated_at" datetime ); CREATE UNIQUE INDEX "index_invitations_on_recipient_email_and_team_id" ON "invitations" ("recipient_email", "team_id"); CREATE INDEX "index_invitations_on_sender_id" ON

SQLite3::NotADatabaseException (file is encrypted or is not a database) in production (Engineyard)

一笑奈何 提交于 2019-12-11 16:28:15
问题 I am trying to parse a sqlite3 database in rails 3 (using sqlite3-ruby gem). The database to parse is coming from a file upload. Here is my controller code: require 'fileutils' require 'sqlite3' tmp = params[:file_upload][:my_file] file = params[:file_upload][:my_file].tempfile filename = params[:file_upload][:my_file].original_filename file = File.join("public", params[:file_upload][:my_file].original_filename) FileUtils.cp tmp.path, filename db = SQLite3::Database.new(filename) So it works

How to install ruby interface for sqlite3 in Mac snow leopard?

浪尽此生 提交于 2019-12-11 08:36:07
问题 I tried to install it as below but it throws error :- "sudo gem install sqlite3-ruby" Building native extensions. This could take a while... ERROR: Error installing sqlite3-ruby: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/ Versions/1.8/usr/lib/ruby/ruby.h Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/sqlite3

Time fields in Rails coming back blank

这一生的挚爱 提交于 2019-12-11 01:53:21
问题 I have a simple Rails 3.b1 (Ruby 1.9.1) application running on Sqlite3. I have this table: create_table :time_tests do |t| t.time :time end And I see this behavior: irb(main):001:0> tt = TimeTest.new => #<TimeTest id: nil, time: nil> irb(main):002:0> tt.time = Time.zone.now => Mon, 03 May 2010 20:13:21 UTC +00:00 irb(main):003:0> tt.save => true irb(main):004:0> TimeTest.find(:first) => #<TimeTest id: 1, time: "2000-01-01 20:13:21"> So, the time is coming back blank. Checking the table, the

Escaping Strings For Ruby SQLite Insert

百般思念 提交于 2019-12-09 12:17:26
问题 I'm creating a Ruby script to import a tab-delimited text file of about 150k lines into SQLite. Here it is so far: require 'sqlite3' file = File.new("/Users/michael/catalog.txt") string = [] # Escape single quotes, remove newline, split on tabs, # wrap each item in quotes, and join with commas def prepare_for_insert(s) s.gsub(/'/,"\\\\'").chomp.split(/\t/).map {|str| "'#{str}'"}.join(", ") end file.each_line do |line| string << prepare_for_insert(line) end database = SQLite3::Database.new("