From 957ecc630bd7c2a5c047a357843d59f81edc9353 Mon Sep 17 00:00:00 2001 From: Hugues Valois Date: Tue, 23 May 2017 15:00:20 -0700 Subject: [PATCH 1/2] Add test for bug #13206. --- pandas/tests/io/test_sql.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 7b3717281bf89..0d5b34e40a39b 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -816,6 +816,11 @@ def test_unicode_column_name(self): df = DataFrame([[1, 2], [3, 4]], columns=[u'\xe9', u'b']) df.to_sql('test_unicode', self.conn, index=False) + def test_escaped_table_name(self): + # GH 13206 + df = DataFrame({'A': [0, 1, 2], 'B': [0.2, np.nan, 5.6]}) + df.to_sql('d1187b08-4943-4c8d-a7f6-6c06b7cb9509', self.conn, index=False) + @pytest.mark.single class TestSQLApi(SQLAlchemyMixIn, _TestSQLApi): From bc3a99dfe13438caa525293b243f4e641b99ce7b Mon Sep 17 00:00:00 2001 From: Hugues Valois Date: Fri, 26 May 2017 14:56:09 -0700 Subject: [PATCH 2/2] Improve test by reading back the values from sql and comparing. Also fixes coding style violation. --- pandas/tests/io/test_sql.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 0d5b34e40a39b..a6ad44ba31422 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -819,7 +819,12 @@ def test_unicode_column_name(self): def test_escaped_table_name(self): # GH 13206 df = DataFrame({'A': [0, 1, 2], 'B': [0.2, np.nan, 5.6]}) - df.to_sql('d1187b08-4943-4c8d-a7f6-6c06b7cb9509', self.conn, index=False) + df.to_sql('d1187b08-4943-4c8d-a7f6', self.conn, index=False) + + res = sql.read_sql_query('SELECT * FROM `d1187b08-4943-4c8d-a7f6`', + self.conn) + + tm.assert_frame_equal(res, df) @pytest.mark.single