Repository: ClearcodeHQ/pytest-mysql (language: python)

Issue:
Databases with hyphenated names cause a syntax error
### What action do you want to perform
```
mysql = factories.mysql("mysql_in_docker", dbname="my-db-test")
```

### What are the results
```
query = 'CREATE DATABASE my-db-test DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci'
...
E       MySQLdb._exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-production DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci' at line 1")
```

### What are the expected results

To insert a string like that, just wrap the name with quotes
```
query = 'CREATE DATABASE 'my-db-test' DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci'
```


Discussion / hints:
How about adding quotes here? https://github.com/ClearcodeHQ/pytest-mysql/blob/7146f105c8acf08a0c32f181f6b39a028199d004/src/pytest_mysql/factories/client.py#L118

Fix patch:
diff --git a/CHANGES.rst b/CHANGES.rst
index a80100ba..244eca6f 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -1,6 +1,14 @@
 CHANGELOG
 =========
 
+unreleased
+----------
+
+Bugs
+++++
+
+- Now will accept correctly database names with hyphen
+
 2.3.0
 ----------
 


Test patch:
diff --git a/src/pytest_mysql/factories/client.py b/src/pytest_mysql/factories/client.py
index bf61e2fe..e0790862 100644
--- a/src/pytest_mysql/factories/client.py
+++ b/src/pytest_mysql/factories/client.py
@@ -115,7 +115,7 @@ def mysql_fixture(request: FixtureRequest) -> MySQLdb.Connection:
             connection_kwargs["port"] = process.port
 
         query_str = (
-            f"CREATE DATABASE {mysql_db} "
+            f"CREATE DATABASE `{mysql_db}` "
             f"DEFAULT CHARACTER SET {charset} "
             f"DEFAULT COLLATE {collation}"
         )
@@ -129,7 +129,7 @@ def mysql_fixture(request: FixtureRequest) -> MySQLdb.Connection:
             mysql_conn: MySQLdb.Connection = _connect(
                 connection_kwargs, query_str, mysql_db
             )
-        mysql_conn.query(f"USE {mysql_db}")
+        mysql_conn.query(f"USE `{mysql_db}`")
         yield mysql_conn
 
         # clean up after test that forgot to fetch selected data
@@ -141,7 +141,7 @@ def mysql_fixture(request: FixtureRequest) -> MySQLdb.Connection:
             mysql_conn.store_result()
         except Exception as e:
             print(str(e))
-        query_drop_database = "DROP DATABASE IF EXISTS %s" % mysql_db
+        query_drop_database = f"DROP DATABASE IF EXISTS `{mysql_db}`"
         mysql_conn.query(query_drop_database)
         mysql_conn.close()
 
diff --git a/tests/conftest.py b/tests/conftest.py
index 0de0953a..e657783f 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -10,7 +10,7 @@
 
 # pylint:disable=invalid-name
 mysql_proc2 = factories.mysql_proc(port=3308)
-mysql2 = factories.mysql("mysql_proc2")
+mysql2 = factories.mysql("mysql_proc2", dbname="test-db")
 mysql_rand_proc = factories.mysql_proc(port=None)
 mysql_rand = factories.mysql("mysql_rand_proc")
 # pylint:enable=invalid-name