© Sqlephant. All rights reserved.

Sqlephant 

SQL Schema Generator

Create your SQL schema by simply specifying the names of your SQL columns, and marking with a * for primary keys.

Example

Your input (table and column names)…

… will be automatically translated after our AI analyzes it into:

Notice how the SQL types are automatically inferred.

SQL Request Fixer

Having trouble with a SQL request that won’t execute?

Sqlephant will:
    • diagnose the error,
    • provide clear explanations,
    • and generate the corrected SQL request for you.

Example

You input the request with the error…

Here is Sqlephant output…

 

SQL Injection Fixer

Our patent-pending tech doesn’t just detect potential SQL injections in your source code—it corrects them too!

Worried your C#, Java, PHP, or Python source code might contain SQL injections that could pose a risk to your organization?

Simply enter your Git projet directory and send it to our infrastructure: 

Our servers will process the batch and prepare a Zip file for you containing all your corrected methods. Just push a button, and a new Git branch of your current project will be created: all is fully automated, with no hassles, and no troubles.

For example, the following method with a SQL injection vulnerability (it uses a Statement instead of a PreparedStatement):

    /**
     * Gets the film title from the filmId.
     *
     * @param connection the JDBC Connection
     * @param filmId the film_id parameter for the SELECT query
     * @return the value of the title column from the filmId, or null if no film
     * is found
     * @throws SQLException if any SQL error occurs during the execution of the
     * query
     */
    public String getFilmTitle(Connection connection, int filmId) throws SQLException {
        String title = null;
        String sql = "SELECT title FROM film WHERE film_id = " + filmId;

        try (Statement statement = connection.createStatement()) {

            try (ResultSet resultSet = statement.executeQuery(sql)) {
                if (resultSet.next()) {
                    title = resultSet.getString("title");
                }
            }
        }

        return title;
    }

Sqlephant will automatically correct and tag it:

    /**
     * Gets the film title from the filmId.
     *
     * @param connection the JDBC Connection
     * @param filmId the film_id parameter for the SELECT query
     * @return the value of the title column from the filmId, or null if no film
     * is found
     * @throws SQLException if any SQL error occurs during the execution of the
     * query
     */
    //SQLEPHANT_REWRITTEN 2023-07-23 12:59:22.808
    public String getFilmTitle(Connection connection, int filmId) throws SQLException {
        String title = null;
        String sql = "SELECT title FROM film WHERE film_id = ?";

        try (PreparedStatement statement = connection.prepareStatement(sql)) {
            statement.setInt(1, filmId);

            try (ResultSet resultSet = statement.executeQuery()) {
                if (resultSet.next()) {
                    title = resultSet.getString("title");
                }
            }
        }

        return title;
    }

DTO automatic generation

Just select the SQL table you want to wrap from the interface.

Sqlephant will create the full DTO. And if you’d like, we can include comments and the “to string” implementations.

Save hours of tedious work.

Full method generations for DML calls

Just jot down the new SQL call you want to add to your app, and Sqlephant will generate all the surrounding code.

Example

The SQL parametrized query will be seamlessly transformed into a ready-to-use C# / Java / PHP / Python method for immediate integration into your app. (DTO not shown for the sake of simplicity.)

C# Sample

Java Sample

PHP Sample

Python Sample

Text 2 SQL

Sqlephant will turn your text inputs into SQL queries.

Note how it’s able to guess the table and column names…

CRUD Generation

Sqlephant will generate CRUD classes for your basic Create, Read, Update and Delete operations.

(DTO not shown for the sake of simplicity.)

Web App Generation

(Coming Soon)

Sqlephant assists in generating Web Application classes and HTML code, specifically tailored for your primary Create, Read, Update, and Delete (CRUD) operations.

Included in this process is the creation of an annotated, easily modifiable CSS template.

Furthermore, Sqlephant generates aesthetically pleasing, easily updatable HTML menus, cohesively organizing all CRUD operations for a given table.

Provided below is an exemplar of a ready-to-implement Servlet in Java/JDBC, devised for inserting values into a table:

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class FilmInsertServlet extends HttpServlet {

    /**
     * Handles the HTTP POST request to insert a new film into the database.
     *
     * @param request  The HTTP servlet request.
     * @param response The HTTP servlet response.
     * @throws ServletException If any servlet-related error occurs.
     * @throws IOException      If any I/O error occurs.
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        try {
            // Retrieve form parameters
            int filmId = Integer.parseInt(request.getParameter("film_id"));
            String title = request.getParameter("title");
            String description = request.getParameter("description");
            int releaseYear = Integer.parseInt(request.getParameter("release_year"));
            short languageId = Short.parseShort(request.getParameter("language_id"));
            short rentalDuration = Short.parseShort(request.getParameter("rental_duration"));
            double rentalRate = Double.parseDouble(request.getParameter("rental_rate"));
            short length = Short.parseShort(request.getParameter("length"));
            double replacementCost = Double.parseDouble(request.getParameter("replacement_cost"));
            String rating = request.getParameter("rating");
            String[] specialFeatures = request.getParameterValues("special_features");

            // Create FilmDto object and set the values
            FilmDto filmDto = new FilmDto();
            filmDto.setFilmId(filmId);
            filmDto.setTitle(title);
            filmDto.setDescription(description);
            filmDto.setReleaseYear(releaseYear);
            filmDto.setLanguageId(languageId);
            filmDto.setRentalDuration(rentalDuration);
            filmDto.setRentalRate(rentalRate);
            filmDto.setLength(length);
            filmDto.setReplacementCost(replacementCost);
            filmDto.setRating(rating);
            filmDto.setSpecialFeatures(specialFeatures);

            // Create FilmInsertDao object
            FilmInsertDao insertDao = new FilmInsertDao();

            // Get JDBC Connection
            try (Connection connection = Sqlephant.getConnection()) {
                // Call insert method on FilmInsertDao
                insertDao.insert(connection, filmDto);
            }

            // Redirect to a success page
            response.sendRedirect("success.html");
        } catch (Exception e) {
            // Re-throw ServletException with the original exception message
            throw new ServletException(e.getMessage(), e);
        }
    }
}

© Sqlephant - Kawansoft. All rights reserved.