How can i connect to Supabase Database with my .net Api
I couldn't find the answer if you could help me i will be appreciated that
26 Replies
https://supabase.com/docs/guides/database/connecting-to-postgres
they've got an entire guide on how to do it
Connecting to your database | Supabase Docs
Explore the options for connecting to your Postgres database.
i tried i was thinking it was not connecting but it actually was but the problem is i cannot send normal post method to database
i can send post method but i need to add this to the dbcontext
without this code it doesn't work and it gives exception again but it registers the data also i waited like 1 minute to register the data
what exception?
That error has nothing to do with failing to connect.
It is telling you that you are breaking a unique constraint on whatever table you are modifying
for example, trying to insert the same record twice when you require unique names or something similar
oh okay
thank you for the help
you should really pay more attention to errors like this as they are usually pretty helpful
but it is running really slow why is that
not something i can diagnose for you ¯\_(ツ)_/¯
you are interacting with a remotely hosted database
so it could be any number of things
maybe it is because of that thank you i will look into that more deeply
- slow network on your side
- slow network / networking issues on the provider side
- not enough resources given to the database so it takes a long time to process data
- etc
if this is just for simple development you'd probably be better off hosting a postgres database locally
very easy to set one up using docker
can i use that in production ?
no, but they are great for development
and you shouldn't be developing / writing your software against your production database anyways
nor should you be letting client applications connect directly to the database
damn it is getting more complex
why tho
because that means anyone with enough time can figure out your database credentials, log in with them, and do whatever they wanted with the data
then you are saying u have to use public key and url?
no, I'm saying your database access should be hidden behind some service / api layer so that clients are not directly communicating with your database
what kind of product are you trying to make? what is accessing your database?
i mean i don't understand i just asked 5 days ago is it secure to keep my database crediantials in appsettings.json they said it is now you confused me is it
this thing i am doing is api
then you're fine, I said don't let clients connect directly to the database
that is not what your API is
i still stand by saying that you should be using different databases for development and production though
we want to publish a website but we don't know which database we have to use
we don't have enough budget so the supabase was free we lean to that
you are likely not going to get good performance running with the free tier of any database provider
not enough for a serious, released product
(this is assuming people are paying for it)
true
but lets just make the start
so is it secure to connect the database with connection string?
yes, assuming that isn't being exposed to clients
if it is all hidden behind your API then you're fine
then also my appsettings json is in secure too right ?
yes, that is normal
okay then i will dig into the first problem thank you a lot bud
you helped me a lot