Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7975235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:35:47+00:00 2026-06-04T08:35:47+00:00

I’m writing a ruby script that has several select queries. At the beginning of

  • 0

I’m writing a ruby script that has several select queries.
At the beginning of the script I’m initializing a new database connection:

db = Mysql.new 'localhost', 'root', 'pass', 'mydb', 3308

The first select query succeeds, but when it gets to second one the following error occurs:

in `query’: query: not connected (Mysql::Error)

I can solve this by copying the connection initialization line before each query, but I really don’t think that this is the right solution here.

Thanks,
Li

Adding my full script (I’m new at this, so sorry for the miserable style):
(Replaced the original script with a much more simple repro):
In the following code, if I comment out the “SELECT” query and leave only the “INSERT INTO” queries, everything works great. But if I try to run the code as is, I get the above error.

#!/usr/local/bin/ruby -w 

require "mysql"

dbname = "sample_db"

m = Mysql.new 'localhost', 'root', 'passw', 'sample_db', 3306

m.select_db(dbname)

m.query("CREATE TABLE words         
     (          
       german varchar(30),          
       english varchar(30),          
       french varchar(30)         
     )"        
   )

m.query("INSERT INTO words VALUES('Adler', 'eagle', 'aigle')")

results = m.query("SELECT german, english FROM words")

m.query("INSERT INTO words VALUES('Haus', 'house', 'maison')")

m.close
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T08:35:48+00:00Added an answer on June 4, 2026 at 8:35 am

    Found the answer in:

    http://halyph.blogspot.com/2009/08/rails-23-migration-issues-with-mysql_26.html

    seems that this is a common issue, I just had to replace libmysql.dll with:
    http://instantrails.rubyforge.org/svn/trunk/InstantRails-win/InstantRails/mysql/bin/libmySQL.dll

    and then restart my mysql service.
    Note that I already replace my dll (after having installation issues) but only the dll from rubyforge seem to have solved this issue

    Note that another symptom of this issue is sporadic segmentation faults. These also disappeared after replacing the dll

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.