Search code examples
mysqljsondigital-signaturevarchar

What length should I give to a MYSQL VARCHAR field that stores a signature in JSON?


I'm trying to store signatures in a database. I'm using a the signature pad plugin (signaturePad) which converts from canvas to JSON and now want to store the signature in MySQL.

I'm using a VARCHAR field, but I'm not sure which length I should allow. I tried several times and usually end up with a string between 2000 and 3000 characters.

Question:
What should I use for field length in MYSQL? I don't know how the CANVAS=>JSON conversion is done, so maybe someone can give me a pointer on what to expect?

Thanks!


Solution

  • I would not use VARCHAR, I would use TEXT. You may sacrifice performance in doing this, but you won't have to worry about size constraints.

    Edit:

    Also, the maximum of VARCHAR is VARCHAR(65535). Just making a note there..