We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
The requirement of superuser postgresql access is problematic
## Problem
Mathesar needs a Postgres superuser to function correctly, from the docs at https://docs.mathesar.org/installation/build-from-source/ 

## Proposed solution
The mathesar user should not require superuser access. 

## Additional context
The superuser is a global permission meaning that a user that has superuser permission will be able to access (and do stuff) not on the mathesar but *all* the databases of the RDBMS. Considering that many production systems have a single RDBMS hosting many application this is a major problem since the mathsar user won't have any access boundaries on the same RDBMS. The mathesar user access can be unlimited but *must* be bounded without the mathesar database.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `db/install.py`
Content:
```
1 from sqlalchemy import text
2 from sqlalchemy.exc import OperationalError
3 
4 from db import engine
5 from db.sql import install as sql_install
6 from db.types import install as types_install
7 
8 
9 def install_mathesar(
10         database_name, username, password, hostname, port, skip_confirm
11 ):
12     """Create database and install Mathesar on it."""
13     user_db_engine = engine.create_future_engine(
14         username, password, hostname, database_name, port,
15         connect_args={"connect_timeout": 10}
16     )
17     try:
18         user_db_engine.connect()
19         print(f"Installing Mathesar on preexisting PostgreSQL database {database_name} at host {hostname}...")
20         sql_install.install(user_db_engine)
21         types_install.install_mathesar_on_database(user_db_engine)
22         user_db_engine.dispose()
23     except OperationalError:
24         database_created = _create_database(
25             database_name=database_name,
26             hostname=hostname,
27             username=username,
28             password=password,
29             port=port,
30             skip_confirm=skip_confirm
31         )
32         if database_created:
33             print(f"Installing Mathesar on PostgreSQL database {database_name} at host {hostname}...")
34             sql_install.install(user_db_engine)
35             types_install.install_mathesar_on_database(user_db_engine)
36             user_db_engine.dispose()
37         else:
38             print(f"Skipping installing on DB with key {database_name}.")
39 
40 
41 def _create_database(database_name, hostname, username, password, port, skip_confirm=True):
42     if skip_confirm is True:
43         create_database = "y"
44     else:
45         create_database = input(
46             f"Create a new Database called {database_name}? (y/n) > "
47         )
48     if create_database.lower() in ["y", "yes"]:
49         # We need to connect to an existing database inorder to create a new Database.
50         # So we use the default Database `postgres` that comes with postgres.
51         # TODO Throw correct error when the default postgres database does not exists(which is very rare but still possible)
52         root_database = "postgres"
53         root_db_engine = engine.create_future_engine(
54             username, password, hostname, root_database, port,
55             connect_args={"connect_timeout": 10}
56         )
57         with root_db_engine.connect() as conn:
58             conn.execution_options(isolation_level="AUTOCOMMIT")
59             conn.execute(text(f'CREATE DATABASE "{database_name}"'))
60         root_db_engine.dispose()
61         print(f"Created DB is {database_name}.")
62         return True
63     else:
64         print(f"Database {database_name} not created!")
65         return False
66
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/db/install.py b/db/install.py
--- a/db/install.py
+++ b/db/install.py
@@ -1,5 +1,6 @@
+from psycopg.errors import InsufficientPrivilege
 from sqlalchemy import text
-from sqlalchemy.exc import OperationalError
+from sqlalchemy.exc import OperationalError, ProgrammingError
 
 from db import engine
 from db.sql import install as sql_install
@@ -54,12 +55,20 @@
             username, password, hostname, root_database, port,
             connect_args={"connect_timeout": 10}
         )
-        with root_db_engine.connect() as conn:
-            conn.execution_options(isolation_level="AUTOCOMMIT")
-            conn.execute(text(f'CREATE DATABASE "{database_name}"'))
-        root_db_engine.dispose()
-        print(f"Created DB is {database_name}.")
-        return True
+        try:
+            with root_db_engine.connect() as conn:
+                conn.execution_options(isolation_level="AUTOCOMMIT")
+                conn.execute(text(f'CREATE DATABASE "{database_name}"'))
+            root_db_engine.dispose()
+            print(f"Created DB is {database_name}.")
+            return True
+        except ProgrammingError as e:
+            if isinstance(e.orig, InsufficientPrivilege):
+                print(f"Database {database_name} could not be created due to Insufficient Privilege")
+                return False
+        except Exception:
+            print(f"Database {database_name} could not be created!")
+            return False
     else:
         print(f"Database {database_name} not created!")
         return False

{"golden_diff": "diff --git a/db/install.py b/db/install.py\n--- a/db/install.py\n+++ b/db/install.py\n@@ -1,5 +1,6 @@\n+from psycopg.errors import InsufficientPrivilege\n from sqlalchemy import text\n-from sqlalchemy.exc import OperationalError\n+from sqlalchemy.exc import OperationalError, ProgrammingError\n \n from db import engine\n from db.sql import install as sql_install\n@@ -54,12 +55,20 @@\n             username, password, hostname, root_database, port,\n             connect_args={\"connect_timeout\": 10}\n         )\n-        with root_db_engine.connect() as conn:\n-            conn.execution_options(isolation_level=\"AUTOCOMMIT\")\n-            conn.execute(text(f'CREATE DATABASE \"{database_name}\"'))\n-        root_db_engine.dispose()\n-        print(f\"Created DB is {database_name}.\")\n-        return True\n+        try:\n+            with root_db_engine.connect() as conn:\n+                conn.execution_options(isolation_level=\"AUTOCOMMIT\")\n+                conn.execute(text(f'CREATE DATABASE \"{database_name}\"'))\n+            root_db_engine.dispose()\n+            print(f\"Created DB is {database_name}.\")\n+            return True\n+        except ProgrammingError as e:\n+            if isinstance(e.orig, InsufficientPrivilege):\n+                print(f\"Database {database_name} could not be created due to Insufficient Privilege\")\n+                return False\n+        except Exception:\n+            print(f\"Database {database_name} could not be created!\")\n+            return False\n     else:\n         print(f\"Database {database_name} not created!\")\n         return False\n", "issue": "The requirement of superuser postgresql access is problematic\n## Problem\r\nMathesar needs a Postgres superuser to function correctly, from the docs at https://docs.mathesar.org/installation/build-from-source/ \r\n\r\n## Proposed solution\r\nThe mathesar user should not require superuser access. \r\n\r\n## Additional context\r\nThe superuser is a global permission meaning that a user that has superuser permission will be able to access (and do stuff) not on the mathesar but *all* the databases of the RDBMS. Considering that many production systems have a single RDBMS hosting many application this is a major problem since the mathsar user won't have any access boundaries on the same RDBMS. The mathesar user access can be unlimited but *must* be bounded without the mathesar database.\n", "before_files": [{"content": "from sqlalchemy import text\nfrom sqlalchemy.exc import OperationalError\n\nfrom db import engine\nfrom db.sql import install as sql_install\nfrom db.types import install as types_install\n\n\ndef install_mathesar(\n        database_name, username, password, hostname, port, skip_confirm\n):\n    \"\"\"Create database and install Mathesar on it.\"\"\"\n    user_db_engine = engine.create_future_engine(\n        username, password, hostname, database_name, port,\n        connect_args={\"connect_timeout\": 10}\n    )\n    try:\n        user_db_engine.connect()\n        print(f\"Installing Mathesar on preexisting PostgreSQL database {database_name} at host {hostname}...\")\n        sql_install.install(user_db_engine)\n        types_install.install_mathesar_on_database(user_db_engine)\n        user_db_engine.dispose()\n    except OperationalError:\n        database_created = _create_database(\n            database_name=database_name,\n            hostname=hostname,\n            username=username,\n            password=password,\n            port=port,\n            skip_confirm=skip_confirm\n        )\n        if database_created:\n            print(f\"Installing Mathesar on PostgreSQL database {database_name} at host {hostname}...\")\n            sql_install.install(user_db_engine)\n            types_install.install_mathesar_on_database(user_db_engine)\n            user_db_engine.dispose()\n        else:\n            print(f\"Skipping installing on DB with key {database_name}.\")\n\n\ndef _create_database(database_name, hostname, username, password, port, skip_confirm=True):\n    if skip_confirm is True:\n        create_database = \"y\"\n    else:\n        create_database = input(\n            f\"Create a new Database called {database_name}? (y/n) > \"\n        )\n    if create_database.lower() in [\"y\", \"yes\"]:\n        # We need to connect to an existing database inorder to create a new Database.\n        # So we use the default Database `postgres` that comes with postgres.\n        # TODO Throw correct error when the default postgres database does not exists(which is very rare but still possible)\n        root_database = \"postgres\"\n        root_db_engine = engine.create_future_engine(\n            username, password, hostname, root_database, port,\n            connect_args={\"connect_timeout\": 10}\n        )\n        with root_db_engine.connect() as conn:\n            conn.execution_options(isolation_level=\"AUTOCOMMIT\")\n            conn.execute(text(f'CREATE DATABASE \"{database_name}\"'))\n        root_db_engine.dispose()\n        print(f\"Created DB is {database_name}.\")\n        return True\n    else:\n        print(f\"Database {database_name} not created!\")\n        return False\n", "path": "db/install.py"}], "after_files": [{"content": "from psycopg.errors import InsufficientPrivilege\nfrom sqlalchemy import text\nfrom sqlalchemy.exc import OperationalError, ProgrammingError\n\nfrom db import engine\nfrom db.sql import install as sql_install\nfrom db.types import install as types_install\n\n\ndef install_mathesar(\n        database_name, username, password, hostname, port, skip_confirm\n):\n    \"\"\"Create database and install Mathesar on it.\"\"\"\n    user_db_engine = engine.create_future_engine(\n        username, password, hostname, database_name, port,\n        connect_args={\"connect_timeout\": 10}\n    )\n    try:\n        user_db_engine.connect()\n        print(f\"Installing Mathesar on preexisting PostgreSQL database {database_name} at host {hostname}...\")\n        sql_install.install(user_db_engine)\n        types_install.install_mathesar_on_database(user_db_engine)\n        user_db_engine.dispose()\n    except OperationalError:\n        database_created = _create_database(\n            database_name=database_name,\n            hostname=hostname,\n            username=username,\n            password=password,\n            port=port,\n            skip_confirm=skip_confirm\n        )\n        if database_created:\n            print(f\"Installing Mathesar on PostgreSQL database {database_name} at host {hostname}...\")\n            sql_install.install(user_db_engine)\n            types_install.install_mathesar_on_database(user_db_engine)\n            user_db_engine.dispose()\n        else:\n            print(f\"Skipping installing on DB with key {database_name}.\")\n\n\ndef _create_database(database_name, hostname, username, password, port, skip_confirm=True):\n    if skip_confirm is True:\n        create_database = \"y\"\n    else:\n        create_database = input(\n            f\"Create a new Database called {database_name}? (y/n) > \"\n        )\n    if create_database.lower() in [\"y\", \"yes\"]:\n        # We need to connect to an existing database inorder to create a new Database.\n        # So we use the default Database `postgres` that comes with postgres.\n        # TODO Throw correct error when the default postgres database does not exists(which is very rare but still possible)\n        root_database = \"postgres\"\n        root_db_engine = engine.create_future_engine(\n            username, password, hostname, root_database, port,\n            connect_args={\"connect_timeout\": 10}\n        )\n        try:\n            with root_db_engine.connect() as conn:\n                conn.execution_options(isolation_level=\"AUTOCOMMIT\")\n                conn.execute(text(f'CREATE DATABASE \"{database_name}\"'))\n            root_db_engine.dispose()\n            print(f\"Created DB is {database_name}.\")\n            return True\n        except ProgrammingError as e:\n            if isinstance(e.orig, InsufficientPrivilege):\n                print(f\"Database {database_name} could not be created due to Insufficient Privilege\")\n                return False\n        except Exception:\n            print(f\"Database {database_name} could not be created!\")\n            return False\n    else:\n        print(f\"Database {database_name} not created!\")\n        return False\n", "path": "db/install.py"}]}