ChuckBell / MySQL_Connector_Arduino

Database connector library for using MySQL with your Arduino projects.
332 stars 133 forks source link

update database #62

Closed sand007man closed 2 years ago

sand007man commented 5 years ago

I was able to successfully insert and select data from my mysql database the only question i have is can i update a particular column in a table using this library because i haven't seen any mention about UPDATE query!!! Thank you

ChuckBell commented 5 years ago

Yes, you can run any SQL command including UPDATE.

On Fri, Sep 21, 2018 at 04:38 sand007man notifications@github.com wrote:

I was able to successfully insert and select data from my mysql database the only question i have is can i update a particular column in a table using this library because i haven't seen any mention about UPDATE query!!! Thank you

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/62, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4LX72yOQ6MxCNTREYjrJ45ZSl8oVks5udKV0gaJpZM4Wzsq4 .

sand007man commented 5 years ago

Thank you sir for this awesome library & quick reply :)

sand007man commented 5 years ago

Hi, I faced a little issue when I was trying to select a BLOB value from the database. I was not able to fetch all the value from the BLOB field only less of half data that was present in that field got display so is this function "row->values" takes only limited bytes of value?

ChuckBell commented 5 years ago

Yes, the buffer is quite small. You can try increasing the size, but you’re likely to run out of memory trying to retrieve a blob field.

On Thu, Nov 1, 2018 at 01:44 sand007man notifications@github.com wrote:

Hi, I faced a little issue when I was trying to select a BLOB value from the database. I was not able to fetch all the value from the BLOB field only less of half data that was present in that field got display so is this function "row->values" takes only limited bytes of value?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/62#issuecomment-434937275, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4I8lV9QQNP38yyiv7aH1AU4c4UxLks5uqoo6gaJpZM4Wzsq4 .

sand007man commented 5 years ago

I tried to search were i can change the buffer value in Mysql_connection.h, Mysql_connection.cpp and mysql_cursor.h...but was not able to get exactly were you allocated buffer value!! Can you tell me were i can change the buffer value.....and there is MAX_FIELDS in cursor.h....is this what i need to change??

ChuckBell commented 5 years ago

Sorry for the obtuse comment. I was referring to max_allowed_packet in the server and whether your Arduino board has enough memory to read in the entire blob field into memory. Keep in mind the row result (all fields) must fit entirely in memory and if you copy it to a variable, that may mean needing twice the memory. Using large blob fields may be a non-starter for smaller boards.

On Thu, Nov 1, 2018 at 11:02 sand007man notifications@github.com wrote:

I tried to search were i can change the buffer value in Mysql_connection.h, Mysql_connection.cpp and mysql_cursor.h...but was not able to get exactly were you allocated buffer value!! Can you tell me were i can change the buffer value.....and there is MAX_FIELDS in cursor.h....is this what i need to change??

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/62#issuecomment-435062728, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4FWOSVc-eG_fRIRCTBZvw6jbFxySks5uqw0fgaJpZM4Wzsq4 .

Bolukan commented 5 years ago

I guess it is the client buffer of the internet client. Package.cpp contains no limit. Can tou guess the size? How much data do you receive?

sand007man commented 5 years ago

Sorry for the obtuse comment. I was referring to max_allowed_packet in the server and whether your Arduino board has enough memory to read in the entire blob field into memory. Keep in mind the row result (all fields) must fit entirely in memory and if you copy it to a variable, that may mean needing twice the memory. Using large blob fields may be a non-starter for smaller boards. On Thu, Nov 1, 2018 at 11:02 sand007man @.***> wrote: I tried to search were i can change the buffer value in Mysql_connection.h, Mysql_connection.cpp and mysql_cursor.h...but was not able to get exactly were you allocated buffer value!! Can you tell me were i can change the buffer value.....and there is MAX_FIELDS in cursor.h....is this what i need to change?? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#62 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4FWOSVc-eG_fRIRCTBZvw6jbFxySks5uqw0fgaJpZM4Wzsq4 .

OK will do the necessary changes in my .cnf file and will check if i am getting complete data or atleast more than before . Btw my BLOB data is about 1400 bytes and the board i am using is node-mcu 12e

sand007man commented 5 years ago

I guess it is the client buffer of the internet client. Package.cpp contains no limit. Can tou guess the size? How much data do you receive?

Hi bolukan, My Blob data is 1400 byte (approx) it changes with the change in template size and using select query i just getting 20% of entire data for rest all datatype it works perfectly .

ChuckBell commented 5 years ago

Is it text? Can you use SUBSTRING() to select part of the blob field at a time? I've got that to work when I wanted to limit how much data I get per query.

On 11/1/18 2:14 PM, sand007man wrote:

I guess it is the client buffer of the internet client. Package.cpp
contains no limit.
Can tou guess the size? How much data do you receive?

Hi bolukan, My Blob data is 1400 byte (approx) it changes with the change in template size and using select query i just getting 20% of entire data for rest all datatype it works perfectly .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ChuckBell/MySQL_Connector_Arduino/issues/62#issuecomment-435131474, or mute the thread https://github.com/notifications/unsubscribe-auth/AH0j4Bbuxx2PUY_nJKAk0dmkAwHNHhz3ks5uqzoTgaJpZM4Wzsq4.

sand007man commented 5 years ago

{3,1,77,27,120,0,240,30,224,2,224,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,224,0,224,0,224,0,224,0,224,0,240,0,240,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,75,6,105,94,49,10,14,126,32,13,101,190,73,153,12,222,61,34,98,222,60,13,77,223,59,154,76,159,93,167,7,223,58,176,203,95,65,181,72,223,57,185,136,188,63,38,140,61,119,176,220,50,83,153,140,123,64,172,202,27,49,170,13,24,51,187,142,56,87,28,11,25,108,35,94,118,55,42,76,22,59,42,226,247,98,176,134,181,106,165,71,211,105,155,200,176,97,158,8,81,113,167,223,110,107,176,133,73,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,1,73,26,114,0,240,2,224,0,224,0,224,0,224,0,224,0,224,0,240,0,240,0,240,0,240,0,240,0,248,0,248,2,248,2,252,6,255,30,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,69,147,140,158,57,29,34,254,76,65,197,182,56,135,77,223,55,148,204,127,90,161,135,223,62,176,8,159,53,51,74,63,52,57,9,191,86,63,28,255,44,36,204,125,117,175,30,21,110,33,222,250,55,43,138,251,57,162,10,184,79,147,204,25,106,157,158,185,103,159,200,249,99,161,95,22,51,165,75,212,90,13,18,12,83,150,11,19,93,24,200,208,113,43,225,204,86,142,104,138,113,40,201,171,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,} This much big is my template on mysql workbench its showing DATA LENGTH : 1416 bytes so when i use to query SELECT SUBSTRING(name,1,300)...i am only getting data till {3,1,77,27,120,0,240,30,224,2,224,0,192,0,192,0,192,0,192,0,192,0,192,0,192,0,224,0,224,0,224,0,224,0,224,0,240,0,240,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,75,6,105,94,49,10,14,126,32,13,101,190,73,153,12,222,61,34,98,222,60,13,77,223,59,154,76,159,93,167,.....which is equal to 250 in length. I did the changes in the server side as well ..MAX_ALLOWED_PACKET = 16M and even made few changes in query_cache_size = 80M and query_cache_type = 1

ChuckBell commented 5 years ago

The reason you're getting less than you expect is likely due to the fact that the blob is binary. So, character set choices, commas, etc. are all counted. Thus, the SUBSTRING is getting the number of bytes (likely) rather than characters. Now, if you changed the field to TEXT, you'll get exactly 300 characters.

I'm afraid you're stuck trying to nibble that large field on the Arduino. It just doesn't have enough memory to suck it all in at once.

Do you really need the entire blob field data at the Arduino? What are you using it for? I might suggest rethinking that and try coming up with a much smaller memory footprint option. Or, use a bigger Arduino!