pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


mysql test generator
Posted by Anonymous on Mon 21st Jul 2025 18:49
raw | new post
view followups (newest first): mysql test generator by Anonymous

  1. # mysql test generator
  2. integer line_num=0
  3.  
  4. cat <<EOF
  5. DROP DATABASE alphabet_test4;
  6. CREATE DATABASE alphabet_test4;
  7. USE alphabet_test4;
  8.  
  9. CREATE TABLE file_data (
  10.     line_number INT PRIMARY KEY,
  11.     line_text TEXT
  12. );
  13. EOF
  14.  
  15. while IFS= read -r line ; do
  16.     (( line_num++ ))
  17.     # Escape single quotes in the line to prevent SQL injection issues
  18.     # This is a basic escape, for more complex data, consider prepared statements
  19.     escaped_line="${line//\'/\'\'}"
  20.  
  21.     # Insert the line number and text into the table
  22.     printf $'INSERT INTO file_data (line_number, line_text) VALUES (%d, \'%s\');\n' line_num "$escaped_line"
  23. done
  24.  
  25. print -u2 '#Done;\n#Verify with SELECT * FROM file_data ORDER BY line_number;\n'
  26. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at