Chat freely about anything...

User avatar
By J.Silva
#75112 Hello there,

I am inserting a value in a database using:
Code: Select allcursor.execute(INSERT_SQL);


Sometimes this function will generate an ERROR in the SERIAL window , for instance if that value already exists in the database,

I need to have that ERROR in a variable, so I can decide what to do upon that error

I was trying to assign the result to a String, but cursor.execute() returns an iterator,

also tried to read from serial, didn't work :shock:


Please help,
User avatar
By QuickFix
#75114
J.Silva wrote:Please help,

With what?
Upto now you haven't given us any leads (code, set up, ...) we can work with. :roll:

MySQL doesn't run on the ESP8266, so you're probably querying a server with a MySQL db over HTTP, right?
You don't want to access a database directly, for starters because of security issues, but also because of these kinds of problems when things go wrong on the server side.

Write some middleware in PHP (or whatever language you like) for on the server that includes some sort of simple REST interface for your ESP to work with. :idea:
User avatar
By J.Silva
#75118 I've been using MySQL_cursor class in ESP,
now that you say that I'm thinking about dumping this method, and change to php,

How does php work with ESP8266?

I'm confused of how all these codes integrate in ESP,
what is the official ESP language? c++?

how is it more safe?
User avatar
By QuickFix
#75136 Sorry, forget my previous post: I assumed you were talking to MySQL over HTTP, don't know how this cursor-class works.
You should've mentioned the used library (I assume this one).
I'm afraid I can't help you.