Arduino Forum

Products => Arduino Due => Topic started by: Vaclav on Jun 30, 2015, 08:25 pm

Title: SQL on Arduin Due?
Post by: Vaclav on Jun 30, 2015, 08:25 pm

I am looking into implementing LIMITED SQL functions on Arduino Due,
mainly search records for matching data.
I know there are EEPROM libraries, but how about SQL libraries?
I cannot implement SQL externally , it has to be strictly stand alone  "Arduino embedded " text data database analysis.

Google does not help much.

Title: Re: SQL on Arduin Due?
Post by: MorganS on Jun 30, 2015, 10:05 pm
Why? There isn't enough memory to make a database big enough to require SQL.
Title: Re: SQL on Arduin Due?
Post by: mart256 on Jul 01, 2015, 12:31 am
Why? There isn't enough memory to make a database big enough to require SQL.
I second this. I think op needs a Raspberry or a Yun. And why would you need sql on a standalone module.
Title: Re: SQL on Arduin Due?
Post by: Vaclav on Jul 01, 2015, 01:47 am
Why? There isn't enough memory to make a database big enough to require SQL.
Say what?
"...make a database big enough to require SQL"?

"...I think op needs a Raspberry or a Yun. And why would you need sql on a standalone module."


1. The question was  "...but how about SQL libraries?"
2. The project spec is "...limited SQL on Due".

Appreciate the OT comments, actually I don't - you waste your and mine time, but how about real advise on the subject of SQL library and you let ME worry about how I need to implement it on Due?
Anybody? For real, please.

Better to remain silent and be thought a fool than to speak out and remove all doubt.

Abraham Lincoln





Title: Re: SQL on Arduin Due?
Post by: MorganS on Jul 01, 2015, 04:06 am
Vaclav, you've been here long enough to have seen the X-Y problem (http://xyproblem.info) play out badly a hundred times. With a bare, unexplained, question like that, you've got to expect more questions before you get a useful response.

I've used a lot of SQL professionally. Big databases, terabytes of stupendously complex stuff. I've used little databases with not even enough data to fill a single typed page. These days I can't even point to the computer that's running the database because it's a virtual server in the datacenter.

If I need an SQL database on the move, disconnected from the internet and company data centers, then I might consider downloading a copy of Oracle onto my laptop. I think I've got a couple of SQL Server implementations running right now. MySQL is also good. I use that on my personal website. If one of those three has an official port to the Due, then I'd like to try it.

But for the kind of stuff that fits on an Arduino, why oh why would you need an SQL interpreter occupying 90% of your program space? What possible useful program fits into the remaining 10%? What could it be doing with an SD card full of data that can't be done by just opening files and reading them?

Real advice: grab the source code for MySQL and start trimming it down to fit the Due. When you think you understand it, step back for a moment because you don't.
Title: Re: SQL on Arduin Due?
Post by: Vaclav on Jul 01, 2015, 05:45 am
Why? There isn't enough memory to make a database big enough to require SQL.
Thanks for reply.
Unfortunately I was not in position to directly question your statement for same reasons you mentioned in you reply.

I still do not get why people almost always ask - why do you want to do that?, and than get upset when I reply - none of you business why.

They are just fishing and not really helping with real answers.

So here it is - English is not my primary language, and you have probably figure that one out by now anyway.

So I read your note as

you need big database to be able to use SQL

which to me was nonsense.

If I want  SQL like code to do search for text record why would my database have to be "big enough to require ( full flown ) SQL?"

So if details are so necessary to receive decent answers - I anticipate 1000 +-  text records , probably 32 characters long in my database. Due can handle that easy.

I am still in "feasibility study " stage and I am really limited to use Due as standalone hardware - power issue.

So all this "stuff " about servers, laptops , SD, why   etc. is of no use to me.
Good night.
Vaclav
 






Title: Re: SQL on Arduin Due?
Post by: MorganS on Jul 01, 2015, 06:56 am
The bigness is important because you don't usually want the text of your SQL statements to be bigger than the data that's in the database.

Code: (Trivially simple SQL statement) [Select]
SELECT employees.category AS Group,
  count(employees.employeeID) as "Count",
  sum(salary) AS Total,
  sum(salary)/count(employees.employeeID) AS Average
FROM employees
  INNER JOIN remuneration
    ON employees.employeeID = remuneration.employeeID
WHERE employees.departmentID IN
    (SELECT departmentID FROM departments WHERE location = 'North Office')
GROUP BY employees.category
HAVING "Count" > 2
ORDER BY employees.category;


Just trying to store that string in the smaller Arduinos looks like a bad idea, let alone the program which is capable of parsing it. Now you may say that you want a limited subset of SQL, without views, subqueries, grouping, sorting and column renaming. But if your subset is that limited, what can you do that you can't easily do with just reading a file? Do you even have a CREATE TABLE command in your plan?

OK, so you only have enough power for a Due and a keyboard and an LCD screen and you like typing SQL and you don't need it to be complex, because the SQL must fit on the screen and you like scrolling through 10 results line-by-line on a small LCD?

A quick Google search finds SQLite (https://www.sqlite.org/about.html) which claims to be able to run in "as little as 100KiB heap space". That's already bigger than all the SRAM the Due has, so it's not going to work.
Title: Re: SQL on Arduin Due?
Post by: MorganS on Jul 01, 2015, 06:57 am
I didn't even put any comments in the SQL code. Just parsing the comments out is a task that's beyond 99% of all Arduino programmers.
Title: Re: SQL on Arduin Due?
Post by: Vaclav on Jul 01, 2015, 03:05 pm
Thanks for reply.
I really was not ready to discuss project details at this point.
And being in 99% group really does not bother me either.
I asked because I have working program doing what I need to do and I like to port it to Arduino using SQL.

And in my naivety I though some limited edition of SQL would be nice.

I do not need to build / input SQL , all I want to execute simple search to match the text entered.
The original SQL does more, but I do not need anything fancier for now.

In conclusion - doing the search using code instead of SQL is the way to go. KISS.

Thanks for your input.

Title: Re: SQL on Arduin Due?
Post by: mrburnette on Jul 03, 2015, 05:12 am
<...>
And in my naivety I though some limited edition of SQL would be nice.
I think the question that should be asked is, "How limited?"

Years ago, I wrote a scientific calculator using a parsing technique which may lend itself to a non-structured set of input criteria.  Anyway, never-say-never...

Anyway, here is the calculator code:
Scientific calculator (http://www.instructables.com/id/Arduino-Scientific-Calculator/?ALLSTEPS)

Ray
Title: Re: SQL on Arduin Due?
Post by: Vaclav on Jul 03, 2015, 01:44 pm
Thanks Ray,
how refreshing , finally someone with "can do attitude".
I appreciate it.
Title: Re: SQL on Arduin Due?
Post by: MarkT on Jul 06, 2015, 11:02 pm
Do you need a language, or do you just need simple relational semantics?