#mysql writes issue error while reads work fine
14 messages · Page 1 of 1 (latest)
You sure it's related to the type of operation? Or could it be because it is a different db instance (which doesn't have the proper DSN configured)
I'm not sure how that could be since I'm only using the DSN in one place. the one thing I can think of around the different db instance being a concern is that go endpoint is run as a serverless function. however, code-wise, it's being in just a single spot
and the code is db, err := sql.Open(dialect.MySQL, os.Getenv("MYSQL_DSN")) using entgo.io/ent/dialect/sql
and can you show some context of where you do the read/writes? and how this db instance gets there
oh weird. I just ran a select query and I'm getting the same issue now
In a way, that's good news I guess 😅
Can you verify that the os.Getenv call actually returns the correct DSN
I'm getting an empty string. I think this only started happening once I moved the hardcoded dsn into an envvar. I'm trying to access it using mysqlDsn := os.Getenv("MYSQL_DSN") and it's defined in .env.local
I was able to run inserts just fine, come to think of it, when the dsn was hardcoded before moving it. I reverted the change and it runs fine again. now I need to find how to access the envvar
I don't. I'm trying to work with go serverless functions in vercel: https://vercel.com/docs/projects/environment-variables , which looks like it doesn't recognize .env.local files for serverless functions but only for its frontend client
Aha, sorry. I don't really have any experience with Vercel 🙂 But it looks like you're on the right track to fix it
that's counterintuitive and upsetting