简体   繁体   中英

How can I take a SQL file and have it import into Rails Active Record base connection?

I know how to execute raw SQL and I've found this command from other SO answers, ActiveRecord::Base.connection.execute(IO.read("Dump20171031.sql")) but I have no idea where I need to put this/what to do with it. I'm doing a class project and my partner has added some test data to a database and we're simply trying to connect the database, a .sql file, with the Rails backend

You can put that line into rails console and it should work. Go to your rails project and type rails console to get into the console.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM