On Tue, 4 Jun 2002, Bart Lateur wrote:

BL> I'm interested in creating SQL batch files, containing SQL statements.
BL> MySQL user may compare them to the output mysqldump produces. In order
BL> to properly generate INSERT statements with string values, I need to
BL> properly quote them. Now, I could use the quote() method from a DBI
BL> connection handle. The only thing is: I don't need a DBI connection, I
BL> may even not have access to a database, I just want access to the quote
BL> method associated with some DBD driver. What's the best way to do that?

If your data just text then something like:

  if (defined $value) { $value =~ s/'/''/g } else { $value = 'NULL' }
  print "insert into some_table values('$value');\n"

would probably suit your needs.  Some databases quote differently
though.

-- 
[EMAIL PROTECTED]

  • quote Bart Lateur
    • tim peters

Reply via email to