Search code examples
mysqlescapingsingle-quotes

mysql dropping database with single quotes in title


So, my python script created a database named 'blabla'. When I try to DROP DATABASE blabla - it doesn't exist. When I try any possible combinations of \'blabla\' "'blabla'" - non of them works and I get syntax error. Using mysql.. Any advice?


Solution

  • You have to use backticks to escape special characters:

    DROP DATABASE `'blabla'`