I know that for mysql em-mysql exists as an asynchronous interface driver to MySQL and that Active Record, with some modification, can make immediate use of. I believe Sequel has this capability already. I also understand that the pg gem exposes PostgreSQL's native async API.
My question: is there any Ruby ORM that natively interoperates with EventMachine when the backing database is PostgreSQL? If not, what needs to be done to retrofit Sequel to support async PostgreSQL? ActiveRecord?
This looks like it works with ActiveRecord:
https://github.com/mperham/em_postgresql
Related
It does not appear the ruby based sequel toolkit (currently at v4.32.0 I believe) supports the JSON datatype which mysql introduced with v5.7. Can somebody confirm that is true and suggests workarounds for migrations and queries? Also whether there are plans to introduce it.
Sequel doesn't currently support MySQL's JSON type.
There aren't any near-future plans to implement support for it, though something like a mysql_json extension should be fairly easy to support on the MySQL adapter. The mysql2 adapter would be trickier as it does all of its own typecasting.
I'm a newbie to all of this. I'm running a project that uses the sqlite3 Ruby gem, but for some reason one of the table exists already. The project contains a ".sql" and ".db" file, among others.
How can you "view" or manipulate this database if it's running from a sqlite3 gem? Specifically, can you bundle exec rake, etc on it?
From a Rails perspective Sqlite works the same as any other database such as PostreSQL or MySQL in that you can run rake tasks on it (e.g. rake db:create, or db:setup, db:reset, db:migrate, etc. all work as expected). You can also use the rails console to query for or insert new data via your active record model objects.
From a non-Rails perspective, Sqlite has various command-line and GUI interfaces that you can install to interact with a Sqlite database using SQL commands.
I would like to use ActiveRecord in a project without Rails.
I would also like to specify the database connections in config/database.yml like Rails does.
There is already one answer how multiple database connections work with Rails.
ActiveRecord talk to two databases?
I was unsuccessful using this approach and I'm not sure why. I only get the error message "database configuration does not specify adapter".
Is there some kind of magic in Rails that reads the database.yml that is not in ActiveRecord?
I could read it myself but then I don't know how to feed it to ActiveRecord so that I can use establish_connection in each model.
I found out how it works. You just fill the ActiveRecord::Base.configurations hash and then it works.
http://apidock.com/rails/ActiveRecord/Base/configurations/class
I have a problem with migrating my SQLite3 database to PostgreSQL. How and what do I need to do?
I am searching the internet, but find only migrations from MySQL to PostgreSQL.
Can anyone help me?
I need to convert my SQLite database to PostgreSQL database for Heroku cloud hosting.
You don't want to try to do a binary conversion.
Instead, rely on exporting the data, then importing it, or use the query language of both and using selects and inserts.
I HIGHLY recommend you look at Sequel. It's a great ORM, that makes switching between DBMs very easy.
Read through the opening page and you'll get the idea. Follow that by reading through the cheat sheet and the rest of the documentation and you'll quickly see how easy and flexible it is to use.
Read about migrations in Sequel. They're akin to migrations in Rails, and make it very easy to develop a schema and maintain it across various systems.
Sequel makes it easy to open and read the SQLite3 table, and concurrently open a PostgreSQL database and write to it. For instance, this is a slightly modified version of the first two lines of the "cheat sheet":
SQLITE_DB = Sequel.sqlite('my_blog.db')
PGSQL_DB = Sequel.connect('postgres://user:password#localhost/my_db')
Base all your subsequent interactions with either database using SQLITE_DB and PGSQL_DB and you'll be on your way to porting the data.
The author of Sequel is very responsive and is a big fan of PostgreSQL, so the ORM has great integration with all its features.
Is there a way to connect ruby to mssql without using DBI? Is there any native Ruby TDS lib that handles that?
FreeTDS comes to mind, however I have not used it.
Java TDS to MSSQL.
Ruby ODBC or Java ODBC
SOAP using TDS endpoints.
The MSSQL DBI is by far the better out of the lot of them. However I guess if you are running Linux and trying to connect to MSSQL, then try "FreeTDS". There are heaps of tut's and sites to show how to setup and configure for all flavours of Linux.
I've published an example application how to connect to an MS SQL Server with ruby, you can check it here.
It mask use of activerecord-sqlserver-adapter to allow ORM.