Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 未初始化常量SQLite错误_Ruby_Sqlite_Nameerror - Fatal编程技术网

Ruby 未初始化常量SQLite错误

Ruby 未初始化常量SQLite错误,ruby,sqlite,nameerror,Ruby,Sqlite,Nameerror,当我添加代码以访问.sqlite数据库时,就会出现一个奇怪的错误: in 'total': uninitialized constant Test2::SQLite (NameError) 我的代码如下: Test1.rb require_relative 'Test2.rb' co = Test2.new() price = co.total Test2.rb require 'sqlite3' class Test2 def initialize()

当我添加代码以访问.sqlite数据库时,就会出现一个奇怪的错误:

in 'total': uninitialized constant Test2::SQLite (NameError)
我的代码如下:

Test1.rb

require_relative 'Test2.rb'

co = Test2.new()
price = co.total
Test2.rb

require 'sqlite3'

class Test2

    def initialize()
            @items = []
    end

    def total()
        db = SQLite::Database.open "Database.sqlite"
        db.close()
        return 0
    end
end

SQLite
模块不存在,但其名称为
SQLite3
():


它偶尔会发生一次。。。至少对我来说:)
require 'sqlite3'

class Test2

    def initialize()
            @items = []
    end

    def total()
        db = SQLite3::Database.open "Database.sqlite"
        db.close()
        return 0
    end
end