FAQ |
Kalender |
|
Ämnesverktyg | Visningsalternativ |
|
![]() |
#1 | ||
|
|||
Klarade millennium-buggen
|
Citat:
successfully installed.... Kod:
C:\Projects\Conny\Ruby\MySQL2\mysql2-master>gem install mysql2 Fetching: mysql2-0.3.11-x86-mingw32.gem (100%) ====================================================================================================== You've installed the binary version of mysql2. It was built using MySQL Connector/C version 6.0.2. It's recommended to use the exact same version to avoid potential issues. At the time of building this gem, the necessary DLL files where available in the following download: http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin ====================================================================================================== Successfully installed mysql2-0.3.11-x86-mingw32 Parsing documentation for mysql2-0.3.11-x86-mingw32 unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/mysql2/1.8/mysql2.so, skipping unable to convert "\x90" from ASCII-8BIT to UTF-8 for lib/mysql2/1.9/mysql2.so, skipping Installing ri documentation for mysql2-0.3.11-x86-mingw32 1 gem installed C:\Projects\Conny\Ruby\MySQL2\mysql2-master> Körde även koden enligt exempel i ReadMe-filen: Kod:
# File: mysql2_test.rb client = Mysql2::Client.new(:host => "localhost", :database => 'test', :username => "root", :password => '**************') results = client.query("SELECT * FROM players") results.each do |row| puts row end Kod:
C:\Projects\Conny\Ruby\Hello>ruby mysql2_test.rb mysql2_test.rb:1:in `<main>': uninitialized constant Mysql2 (NameError) C:\Projects\Conny\Ruby\Hello> Jag kör senaste version av Ruby dvs 2.0.0p195 Senast redigerad av Conny Westh den 2013-07-04 klockan 00:31 |
||
![]() |
![]() |
![]() |
#2 | ||
|
|||
Flitig postare
|
Har du importerat mysql2 i din kod?
`require "mysql2"` |
||
![]() |
![]() |
![]() |
#3 | ||
|
|||
Klarade millennium-buggen
|
Jag har testat både med och utan med samma resultat, dvs det blir fel.
Använder jag require "mysql2" så får jag dock betydligt fler felrader enligt: Utan require: Kod:
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. Med ensamrätt. C:\Projects\Conny\Ruby\Hello>ruby mysql2_test.rb mysql2_test.rb:1:in `<main>': uninitialized constant Mysql2 (NameError) Kod:
Microsoft Windows [Version 6.1.7601] Copyright (c) 2009 Microsoft Corporation. Med ensamrätt. C:\Projects\Conny\Ruby\Hello>ruby mysql2_test.rb C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require': cannot load such file -- mysql2/2 .0/mysql2 (LoadError) from C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from C:/Program Files (x86)/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (requ ired)>' from C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require' from C:/Program Files (x86)/Ruby200/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11-x86-mingw32/lib/mysql2.rb:9:in `<top (required)>' from C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `require' from C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:110:in `rescue in require' from C:/Program Files (x86)/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:35:in `require' from mysql2_test.rb:1:in `<main>' C:\Projects\Conny\Ruby\Hello> Senast redigerad av Conny Westh den 2013-07-04 klockan 01:08 |
||
![]() |
![]() |
Svara |
|
|