2

Is it possible to use single XML file for Ruby on Rails as an ActiveRecord database?

totocaster
  • 6,243
  • 5
  • 37
  • 46

4 Answers4

5

No, AFAIK,

I would suggest you to use sqlite3 as database, since it's lightweight and small. If you want to generate XML from that, you can just use to_xml method :)

sikachu
  • 1,212
  • 8
  • 16
  • Yes, I think that't the way I'll use, because there are no working XML adapters for ActiveRecord over the net :( – totocaster Jan 09 '09 at 16:26
  • Why is this an answer? Everything is possible, or is rails all of the sudden not Turing complete? You just don't know how. Now I have to go find out how to actually do it. – baash05 Apr 04 '12 at 02:34
3

Read this stackoverflow posting for a rundown on this topic. The answer boils down to scalability and data integrity. At some point the data file will get big enough that it will need on-disk indexes, which are not directly supported in XML. Also, an XML file is not transactional - it has no logs. To implement a transactional storage in an XML file you would have to implement a DBMS, and create supplemental transactional log and index files. This is almost certainly far more trouble than it's worth.

Community
  • 1
  • 1
ConcernedOfTunbridgeWells
  • 64,444
  • 15
  • 143
  • 197
  • Thanks.. now this should be the answer.. yeah it's hard, and it shouldn't be done for anything lasting. But it can be done. – baash05 Apr 04 '12 at 02:35
1

I'd say it was possible, but you really wouldn't want to do it!

It would involve writing a new XML ActiveRecord adapter that would issue XPath (presumably) queries against your file where the other adapters would generate SQL. I suppose you'd also need migrations to maintain XSD or DTD files.

It's horrible. Don't do it.

Mike Woodhouse
  • 51,832
  • 12
  • 88
  • 127
0

https://rubygems.org/gems/xml_active seems to do the job. I'm digging deeper, but it is where I'm starting.

baash05
  • 4,394
  • 11
  • 59
  • 97