Embedded MongoDB instance? - ruby

I've been using MongoDB for a little tool that I'm building, but I have two problems that I don't know if I can "solve". Those problems are mainly related with having to start a MongoDB server (mongod).
The first is that I have to run two commands every time that I want to use it (mongod and my app's command) and the other is testing. For now, I'm using different collections for "production" and "test", but it would be better to have just an embedded / self-contained instance that I can start and drop whenever I want.
Is that possible? Or should I just use something else, like SQLite for that?
Thanks!

Another similar project is https://github.com/Softmotions/ejdb.
The query syntax is similar to mongodb.

We use this at work - https://github.com/flapdoodle-oss/embedmongo.flapdoodle.de - to fire up embedded Mongo for integration tests. Has worked really well.

I haven't tried it, but I just found this Ruby implementation of an embedded MongoDB: https://github.com/gdb/embedded-mongo

Related

could not init postgres with a dump file

just starting testcontainers. I love the idea. thanks for investing in this project.
I am trying to create a simple postgres 14.5 container (and susceeded) and now I am trying to populate it using the .withInitScript() method.
the file I am feeding into the init method is a dump I created with pg_dumpall.
testcontainers fails for many parsing/validation reasons. each time I delete a portion and another reason pops up.
should I be able to succesfully use the withInitScript with pg_dump files?
BTW, using pg_dump for my main DB also has many similar issues.
thanks!
Try copying the script to the container so postgres will execute. Although this comment BTW, using pg_dump for my main DB also has many similar issues. makes me wonder if it will work because it also fails when you are using the database directly if I understood correctly.
new PostgreSQLContainer("postgres:14.5")
.withCopyFileToContainer(
MountableFile.forClasspathResource("init.sql"),
"/docker-entrypoint-initdb.d/init.sql"
);
We recommend to use liquibase or flyway to manage database changes.
hi and thanks for the help
I have managed to make things work by stripping some things from the sql dump and using the copyFileToContainer
thanks

Where can I find the mongoDB database

i install the meteor package and within is the mongoDB. Now I made an easy application and create a mongo db collection ...
Todos = new Mongo.Collection('todos');
I write data in this collection and everything works fine. BUT! I can not find the mongodb and the collections an my Mac?! I read on some sites that I have to watch at /data/db but on my mac there is not such a file...
Can anyone explain where mongoDb takes the data on my Mac.
Thank you
Countless duplicates to this one if you use the search engine, but a short answer would be to look inside: .meteor/local/db

Start Embedded MongoDB with RSpec?

Is there such thing as an embedded version of MongoDB suitable for use with RSpec, that can be started with a suite of tests?
In JavaLand, where I normally live when I'm not vacationing in the United States of Ruby, we are in the habit of starting portable embedded versions of database servers when we run tests, such as this Java-embeddable MongoDB.
Is there an equivalent for Ruby? Or do we always expect developers to have a local MongoDB running?
Currently, our replica set tests use a MongoConfig test tool to bring up RS members:
https://github.com/mongodb/mongo-ruby-driver/blob/1.x-stable/test/tools/mongo_config.rb
Check out this method for how to use it:
https://github.com/mongodb/mongo-ruby-driver/blob/1.x-stable/test/helpers/test_unit.rb#L38-L62
We don't use it for our non-replica set tests, but I don't see why you couldn't use it yourself. I also don't see anything about Rspec in particular that would make this difficult either.

How to profile Doctrine MongoDB ODM?

How can I profile Doctrine MongoDB ODM?
I would like to see all queries against database and the time of execution. Is there any way to configure a profiler? I would like to build a plugin that I would use it in ZFDebug toolbar.
The MongoDBODMModule for ZF2 may have some classes you could re-use to handle this problem in ZF1. If you're already using ZF2, then it is just a matter of installing the module and ZendDeveloperTools to have the toolbar.
MongoDB has its own profiler, check http://docs.mongodb.org/manual/tutorial/manage-the-database-profiler/

Can you connect to a MS Access database from Ruby running on a Mac?

I'm pretty sure the answer is "no" but I thought I'd check.
Background:
I have some legacy data in Access, need to get it into MySQL, which will be the DB server for a Ruby application that uses this legacy data.
Data has to be processed and transformed. Access and MySQL schemas are totally different. I want to write a rake task in Ruby to do the migration.
I'm planning to use the techniques outlined in this blog post: Using Ruby and ADO to Work with Access Databases. But I could use a different technique if it solves the problem.
I'm comfortable working on Unix-like computers, such as Macs. I avoid working in Windows because it fills me with deep existential horror.
Is there a practical way that I can write and run my rake task on my Mac and have it reach across the network to the grunting Mordor that is my Windows box and delicately pluck the data out like a team of commandos rescuing a group of hostages? Or do I have to just write this and run it on Windows?
Why don't you export it from MS-Access into Excel or CSV files and then import it into a separate MySQL database? Then you can rake the new one to your heart's content.
Mac ODBC drivers that open Access databases are available for about $30.00
http://www.actualtechnologies.com/product_access.php is one. I just run access inside vmware on my mac and expore to csv/excel as CodeSlave mentioned.
ODBC might be handy in case you want to use the access database to do a more direct transfer.
Hope that helps.
I had a similar issue where I wanted to use ruby with sql server. The best solution I found was using jruby with the java jdbc drivers. I'm guessing this will work with access as well, but I don't know anything about access

Resources