- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 10:13 AM
driver_manager = spark._sc._gateway.jvm.java.sql.DriverManager
connection = driver_manager.getConnection(mssql_url, mssql_user, mssql_pass)
connection.prepareCall("EXEC sys.sp_tables").execute()
connection.close()
The above code works fine but however I am unable to capture the output Params from Stored Procedure
Can someone please share the snippet to capture output value
- Labels:
-
Azure
-
Azure databricks
-
Stored procedure
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 02:42 PM
I think there is an `executeQuery()` function that also works and returns a resultset. Something like this (I have not tested though):
conn = DriverManager.getConnection(url, username, password);
stmt = conn.createStatement();
sql = "SELECT * FROM mytable";
rs = stmt.executeQuery(sql);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2023 02:42 PM
I think there is an `executeQuery()` function that also works and returns a resultset. Something like this (I have not tested though):
conn = DriverManager.getConnection(url, username, password);
stmt = conn.createStatement();
sql = "SELECT * FROM mytable";
rs = stmt.executeQuery(sql);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2023 03:15 AM
If I print(rs) I am not receiving the expected result
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2023 09:48 AM
Can you provide more details on the output? I am not entirely sure if the print statement would show the value of rs as it may just show the type of the python object since it is not a string variable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-03-2023 04:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2024 01:19 AM
This blog helped me with the output of the stored procedure: https://medium.com/@judy3.yang/how-to-run-sql-procedure-in-databricks-notebook-e28023555565

