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

  • Home
  • SEARCH
  • 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 6255217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:19:24+00:00 2026-05-24T14:19:24+00:00

I have a MongoDB DB with some data. That all works fine, the data

  • 0

I have a MongoDB DB with some data. That all works fine, the data was inserted into the mongo DB properly. What I want to do now, though, is open the mongoDB DB file, and parse it using the BSON gem so that I can look at the human-friendly format of the mongo DB file.

data = nil

File.open("input/bson/database_development.0") do |f|
  data = f.read
end

unpacked_data = BSON.deserialize(data)

File.new("input/bson/output.txt", "w") do |f|
  f.write(unpacked_data)
end

However, this gives me the following error:

/home/user/.rvm/gems/ruby-1.9.2-p180/gems/bson-1.3.1/lib/bson/bson_c.rb:28:in `deserialize': no c decoder for this type yet (-86) (TypeError)
from /home/user/.rvm/gems/ruby-1.9.2-p180/gems/bson-1.3.1/lib/bson/bson_c.rb:28:in `deserialize'
from /home/user/.rvm/gems/ruby-1.9.2-p180/gems/bson-1.3.1/lib/bson.rb:37:in `deserialize'
from bsoner.rb:16:in `<main>'

From google a little bit, some folks said that mongoDB can ACCEPT any kind of input and store it, but can’t READ just any kind of data. So they’re saying that the database file has bad data in it that can’t be read properly. But shouldn’t it be able to read anything that it can insert?

  • 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-05-24T14:19:24+00:00Added an answer on May 24, 2026 at 2:19 pm

    MongoDB is not a file-based database. In order to read the data back out, you need to connect to the running MongoDB server. The BSON gem is for parsing the data returned by the server, not parsing the files themselves.

    To connect to your MongoDB server and read data, you’ll do something like the following:

    require 'rubygems'
    require 'mongo'
    
    connection = Mongo::Connection.new # connects to localhost by default
    db   = connection['sample-db']
    collection = db['test']
    
    outfile = File.open('output.txt', 'w')
    collection.find.each { |doc| outfile.puts doc.inspect }
    

    The collection and db objects have additional methods that will let you get a list of all databases and collections, if you need to print out the data in all of those as well. Check out the API documentation for the mongo gem for more information.

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

Sidebar

Related Questions

Good day, i have mongodb database filled with some data, i ensured that data
I have some data in MongoDB that looks like this: { name: Steve, location:
I have a logging setup in python application that logs into file and MongoDB.
We have a lot of data, decided to use mongodb and it works great.
We have an application that works with financial data that is schemaless. More accurately,
The limitation of one document in MongoDB is 4Mo. I have some documents really
I have a collection of articles in MongoDB that has the following structure: {
All of us have come across the recent hype of no-SQL solutions lately. MongoDB,
Suppose I have some objects in MongoDB: { _id:xxx, name:mike, children: [ {name:A, age:3},
I want to switch from MySQL to MongoDB but great data losses (more than

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.