Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Database file?


Best Answer croll12, 29 July 2014 - 02:21 AM

Thank you all for the responses.  I used to log all the transactions in a database and marked them as either online or offline.  Then a separate query searching for the offline ones and attempts to retry them.  After reading your responses I realized it can be easier and create separate files per transaction when they are offline.  Then have a separate thread retry the transactions periodically and delete them when successful.

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 croll12

croll12

    Member

  • Members
  • PipPip
  • 10 posts

Posted 08 July 2014 - 12:25 AM

I am using a Netduino Plus 2 to call our servers and post transactions with re-loadable cards.  Everything is working great, but I am trying to find a way to store the transactions on the SD card in the event it can not communicate with our servers (internet outage), then when the connection is restored it will try and post the transactions.  I did this previously with .net and mysql.  After reading other posts it is obvious mysql is out for the micro framework.  Are there any ideas that would work similar to a database other than a simple text file?

 

Thanks in advance for the help and ideas.



#2 croll12

croll12

    Member

  • Members
  • PipPip
  • 10 posts

Posted 16 July 2014 - 12:17 PM

Really, 50+ views and not a single reply?



#3 Spiked

Spiked

    Advanced Member

  • Members
  • PipPipPip
  • 129 posts

Posted 16 July 2014 - 04:19 PM

I started to reply. But then I thought I would re-read the question.  Which is;

"Are there any ideas that would work similar to a database other than a simple text file?"

and to that, my answer is no.  

 

I have ideas how I would handle database transactions, with store and forward guaranteed message concepts, involving simple text files, but you asked for something else. That gave me the impression you already know how to do it with simple text files, and I really can not add.

 

For other readers, who  may not know how to use simple text files; identify how you can make a db transaction atomic - ie self contained.

 

Look into things like diff files for ideas and mold the idea to fit your data - I have no real idea what your data looks like, so I can only suggest starting points.

 

Once it is atomic, write it to a separate disk file on the SD card.

 

A different thread, reads ALL files on the SD card one at a time and attempt the transaction with server/database/both. When confirmation is received that the database transaction successfully completed, the file should be erased from the SD card.  This method will survive system and network failures.  If you need to prevent accidental double updates, include a sequence number. If it has already been used indicate a previous transaction succeeded.



#4 Robert Hugo

Robert Hugo

    Advanced Member

  • Members
  • PipPipPip
  • 35 posts

Posted 29 July 2014 - 12:11 AM

You could use XML, which in a sense can be treated or thought of as a "database", as it can also contain hierarchical structure. There are complexities with XML, but it is an option, albeit perhaps a bit contrived.

 

If it is just a matter of single transactions, however, a text file (or several) seems more direct.

 

The file system itself could probably (being unfamiliar with pitfalls using SD cards on the Netduino) be used, treating files in a folder as the transactional records themselves. You could keep all necessary information inside the file itself, even history of attempts, etc. This way files could be removed as they are successfully submitted to the actual database. 

 



#5 croll12

croll12

    Member

  • Members
  • PipPip
  • 10 posts

Posted 29 July 2014 - 02:21 AM   Best Answer

Thank you all for the responses.  I used to log all the transactions in a database and marked them as either online or offline.  Then a separate query searching for the offline ones and attempts to retry them.  After reading your responses I realized it can be easier and create separate files per transaction when they are offline.  Then have a separate thread retry the transactions periodically and delete them when successful.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.