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 8995217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:35:25+00:00 2026-06-15T23:35:25+00:00

I am currently using a MySQL database and am considering moving to Postgres in

  • 0

I am currently using a MySQL database and am considering moving to Postgres in the future. In my code I have:

client = Mysql2::Client.new(:host => "#{DB_HOST}", :username => "#{DB_USERNAME}",
:password => "#{DB_PASSWORD}", :database => "#{DB_NAME}")
sql = "SELECT /*complicated query with joins */ ASC"
data_setter = client.query(sql)

I am concerned that if I move to Postgres I will no longer be able to use the Mysql2 gem and perform queries similar to the code above.

Any advice would be greatly appreciated.

  • 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-15T23:35:26+00:00Added an answer on June 15, 2026 at 11:35 pm

    You can do the same sort of thing but you’ll have to switch to the pg gem as Mysql2 only knows how to talk to MySQL. The interface is similar:

    db  = PG::Connection.new(...)
    sth = db.query('select /* big complicated pile of SQL */')
    sth.each { |row| do_things_with_row(row) }
    

    Generally you can go through ActiveRecord for most things (even raw SQL queries) but if you need to bypass all that and talk directly to the database then you can. You might have some issues with PostgreSQL not standing for the sort of sloppiness that MySQL will though.

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

Sidebar

Related Questions

I'm new to database design and am currently using MySQL Workbench to help me
I am currently using MySQL for my Rails application. In my database.yml, I have
I am currently using the following code to connect to a mysql database, but
Currently using a MySQL database Wanting to insert a new row into a table
I have a MySQL database (currently using phpmyadmin to manage) that I would like
I am currently using PHPmyadmin to store data in my mySQL database. The android
I'm currently developing a website which stores bookmarks in a MySQL database using PHP
Suppose I am building an app using current mysql database tables. I have this
I'm using MySQL and I currently have a VARCHAR column which stores times (in
I am currently using Doctrine's DBAL library for MySQL interfacing and have currently built

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.