SQL API Reference
Database Connection APIs
-
ConnectDatabase(connectionString)
Establishes a connection to the SQL database using the provided connection string.
// Example in C# SqlConnection connection = new SqlConnection(connectionString); connection.Open();
Parameters:
Name Type Description connectionString string The string used to connect to the database. Returns:
A connection object representing the established database connection.
-
DisconnectDatabase(connection)
Closes an active database connection.
// Example in Python connection.close()
Parameters:
Name Type Description connection DatabaseConnection The connection object to be closed.
Query Execution APIs
-
ExecuteQuery(connection, query)
Executes a SQL query and returns the results.
// Example in Java Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT * FROM Users");
Parameters:
Name Type Description connection DatabaseConnection The active database connection. query string The SQL query to execute. Returns:
A result set containing the data returned by the query.
-
ExecuteNonQuery(connection, command)
Executes a SQL command that does not return a result set (e.g., INSERT, UPDATE, DELETE).
// Example in JavaScript (Node.js) db.run("UPDATE Products SET Price = Price * 1.1 WHERE Category = 'Electronics'");
Parameters:
Name Type Description connection DatabaseConnection The active database connection. command string The SQL command to execute. Returns:
The number of rows affected by the command.
Stored Procedure APIs
-
ExecuteStoredProcedure(connection, procedureName, parameters)
Executes a stored procedure with optional parameters.
// Example in SQL (using pseudocode for API call) procedure.execute(connection, 'GetUserByID', { userId: 123 });
Parameters:
Name Type Description connection DatabaseConnection The active database connection. procedureName string The name of the stored procedure to execute. parameters object | array Optional. A map or array of parameters for the stored procedure. Returns:
The result of the stored procedure execution.