SqLite VS XML

Have another debate if you wish. I am wanting to know the possible reasons for choosing either MySql or XML for saving project files. I have been advised on these forums to use XML but MySql seems a little more appealing to me because writing code for it is faster. I believe the files in MySql are atleast partially encrypted an d it seems that writing code is more convenient with MySql. What would the benefit of this and what are the solid reasons for choosing either or. I wing onder what led this person to advise me to use XML? Not saying it is a bad idea. In fact, I know of some programs that use XML files as there main data saving format. I was thinking it might be nice for using to access and make an easy read of the XML so people could easily develop software that uses save formatting that is designed to be opened up in my software.

Thanks

What kind of files are you contemplating?

And do you mean SQLite instead of MySQL?

Yes. I think so, sorry.

Good question. Sorry I do not answer this.

Project files that, if store the names of files that are required to load the project and all other kinds of information such as text. Can you somehow store pictures or other files inside of XML or SqLite files.

Thanks

If the data is going to change, the user is going to add stuff, or you need to retrieve different things at different times then I would say go with SQLite. It’s designed to do that and it’s very fast and lightweight. An XML document isn’t all that hard to do but XML isn’t as straightforward to use, IMO.

In other words, both will do the job but it depends on how you’re going to use them.

If you just need a mechanism to store data from RAM and retrieve it into a RAM later (for example, you’re saving a document), either will do, but XML is easier to edit externally, like with a text editor.

If you need to store and retrieve more information than would practically fit in RAM, use a database.

XML Pros:

  • Text-based, so users can easily view the files (could be a con, I suppose)
  • Easy to work with (no SQL required)

XML Cons:

  • Can be slow for large data sets
  • Not great for binary data

SQLite Pros:

  • Wicked Fast
  • Did I mention it’s fast?

SQLite Cons:

  • Have to use SQL
  • Creates temp files
  • User cannot easily view contents (could be a pro, I suppose)

[quote=57453:@Paul Lefebvre]XML Pros:

  • Text-based, so users can easily view the files (could be a con, I suppose)
  • Easy to work with (no SQL required)

XML Cons:

  • Can be slow for large data sets
  • Not great for binary data

SQLite Pros:

  • Wicked Fast
  • Did I mention it’s fast?

SQLite Cons:

  • Have to use SQL
  • Creates temp files
  • User cannot easily view contents (could be a pro, I suppose)[/quote]
    It does not seem to be a very complex choice to make. What is required to use SQL? Does it just mean I have to learn the basics of the SQL programming language, if it even is one I have no idea. What situation would make it a good or bad thing that people can view your saved data within the project files? Is it just because people can peak into the structure of the program or what? If you don’t mind me asking how is the Xojo save formats laid out? Do you use one class which manages the XML and SQLite for you or do you manually write into the code to perform the same task twice but just programmed for the different save formats?

Thanks this is very good information everybody is giving me

Although this can be overcome by hex-encoding/decoding the data (yes, that would make it slower).

Another potential Pro for SQLite is that they can easily be encrypted.

I also don’t agree that XML is necessarily “easy to work with”. Probably easier than SQL, but still.

I don’t think XML is ‘easy to work with’ either, but then I’ve been doing consistent SQL work for 15+ years whereas I have to do XML coding about once a year. To me XML is just tedious but with the database stuff I just abstract it out to ActiveRecord.

saving project files in a sql database makes them not very friendly to version control systems

text based formats are friendlier - even if they are XML

XML is text, so it is easier to work with than a database that you can only interface with SQL, but YMMV.

It might also be worth considering JSON instead of XML. JSON is also text and is even easier to work with due to its Dictionary-like API in Xojo. Its terseness hurts its readability, though.

Regardless, I’d abstract out the file format to its own class. How it is saved is just an “implementation detail”. :slight_smile:

When I’ve been working with XML recently, I just basically abstracted it out to my own Activerecord-like classes and treat it like a recordset. It depends on the structure of the xml, of course, but for xml that represents a collection of “results”, it works well.

The way I read the OP, is he is asking about saving “project files”… not data files…

XML has benefits for both types of files… which is one reason XOJO has a XML project file type…
mySQL/SQLite etc… while it COULD be used to store source code, it much better suited to DATA…

I’m a little confused about this question, is it concerning user data or Xojo project files? To add to this XML versus text: the big names databases do have a column type XML fo storing ‘raw’ XML, XML that is not supported by an XML scheme. Microsoft: