csteinhilber
Programmer
I have a need to promote a given table from one mySQL server (dev/staging) to another (production)... as the two boxes CAN NOT point to the same mySQL server for various reasons.
One of the solutions I'm implementing is a webservice running on the production box that receives a table description (produced on the staging box via
) and the data to be populated (simple
).
The webservice receptor then creates a temporary table based on the table description it receives, inserts the data, drops any existing table with the destination name if it exists, and renames the temporary table to the destination name.
Everything's working fairly well, except I'm not sure I'm doing it the most efficient way... particularly the "create temporary table". I pretty much take the resultset that's produced by the DESCRIBE function, and loop through it's rows, and parse the fields to assemble a valid table description for CREATE. Is there a way to simply pass CREATE or a similar function the resultset from a DESCRIBE directly? As I say, I've been pretty successful in assembling the CREATE statement manually, but I'm not certain that it will work for ALL (unforeseen) situations.
Or, is there an existing script built by someone who knows more about mySQL than I do that can translate a DESCRIBE resultset to a CREATE statement?
Or, is there a better way to do this altogether? I thought about setting up MASTER/SLAVEs, but this is more of a "promote to production once approved on staging" situation, rather than a "keep production and staging in sync"... so it didn't seem like MASTER/SLAVE was the right way to go.
Anyone?
Thanks much!
-Carl
One of the solutions I'm implementing is a webservice running on the production box that receives a table description (produced on the staging box via
Code:
DESCRIBE table_name
Code:
SELECT * FROM table_name
The webservice receptor then creates a temporary table based on the table description it receives, inserts the data, drops any existing table with the destination name if it exists, and renames the temporary table to the destination name.
Everything's working fairly well, except I'm not sure I'm doing it the most efficient way... particularly the "create temporary table". I pretty much take the resultset that's produced by the DESCRIBE function, and loop through it's rows, and parse the fields to assemble a valid table description for CREATE. Is there a way to simply pass CREATE or a similar function the resultset from a DESCRIBE directly? As I say, I've been pretty successful in assembling the CREATE statement manually, but I'm not certain that it will work for ALL (unforeseen) situations.
Or, is there an existing script built by someone who knows more about mySQL than I do that can translate a DESCRIBE resultset to a CREATE statement?
Or, is there a better way to do this altogether? I thought about setting up MASTER/SLAVEs, but this is more of a "promote to production once approved on staging" situation, rather than a "keep production and staging in sync"... so it didn't seem like MASTER/SLAVE was the right way to go.
Anyone?
Thanks much!
-Carl