0

I have a command to drop postgresql database:

sudo -u myuser psql -c "drop database my_databse"

How I could execute this sentence from an aspnet website(c#)? Is it possible to execute without introducing a password?

This app is running in another server: I have a windows server running aspnet website. I have an ubuntu server running postgresql database.

Za7pi
  • 1,338
  • 7
  • 22
  • 33
  • this might help : http://codeabout.wordpress.com/2012/03/08/working-with-postgres-database-and-c-by-using-npgsql-and-reflection/ – Krunal Patil Jun 16 '14 at 09:32
  • I am using npgsql, but I want directly drop the databse from command in the server. THanks – Za7pi Jun 16 '14 at 09:34

1 Answers1

1

drop database my_databse is an SQL command. You can run it directly from nPgSQL. There is no need to run psql, and no point doing so.

If your usual user account doesn't have the access rights for it, you can make a new temporary connection in nPgSQL just for that command. You might find SET SESSION AUTHORIZATION or SET ROLE useful, too.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778