Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2010
    Posts
    39

    Unanswered: Generating CRUD Stored Procedures

    Has anyone seen a tool for MYSql that generates stored procedures based on the database? Have not used MySQL that much and have found these tools to be helpful in generating the 'start' of stored procedures. I have a new applications that will have quite a few tables that will require this.

    Thanks!

  2. #2
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Hi,

    I have written a script in PHP which basically does what Crud does. It creates 4 stored procedures based on the primary key of the table in a database. If no primary key exists no stored procedures are created. The 4 stored procedures per table include one that perform a select on the entire table, another which selects using the primary key, another one which deletes based on the primary key and the last one which either updates or insert depending on whether the primary key exists.

    This can be downloaded here
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

  3. #3
    Join Date
    Dec 2010
    Posts
    39

    Generating CRUD Stored Procedures

    Thanks for the input and I have downloaded the script. Now I just gotta figure out how to execute it. I am running a VM with TurnKeyLinux with the LAMP stack. I can access PHPMyAdmin, and other things but have no idea where to start.

  4. #4
    Join Date
    Sep 2009
    Location
    San Sebastian, Spain
    Posts
    880
    Hi,

    basically it is a PHP script so this can be run from the command line using:

    Code:
    php phpCrud.php -u <username> -d <database>
    There are additional parameters such as hostname, password and individual table.

    It is not exactly a CRUD where it generates the CREATE table but reverse engineers the stored procedures based on the already existing tables in the database. I identify the primary key of the table and then make sure that access to the data is unique.

    I have also created a mini screencast and have added this to the webpage where you can download the script.
    Ronan Cashell
    Certified Oracle DBA/Certified MySQL Expert (DBA & Cluster DBA)
    http://www.it-iss.com
    Follow me on Twitter

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •