From 5eff5a85c4cbeed6449cc2ab4958cd7760620513 Mon Sep 17 00:00:00 2001 From: EdAbati Date: Mon, 8 Nov 2021 23:27:28 +0100 Subject: [PATCH 1/2] Removed _SAFE_NAMES_WARNING --- pandas/io/sql.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pandas/io/sql.py b/pandas/io/sql.py index ec5262ee3a04c..222ed40519888 100644 --- a/pandas/io/sql.py +++ b/pandas/io/sql.py @@ -1817,12 +1817,6 @@ def _get_valid_sqlite_name(name): return '"' + uname.replace('"', '""') + '"' -_SAFE_NAMES_WARNING = ( - "The spaces in these column names will not be changed. " - "In pandas versions < 0.14, spaces were converted to underscores." -) - - class SQLiteTable(SQLTable): """ Patch the SQLTable for fallback support. @@ -1883,11 +1877,6 @@ def _create_table_setup(self): """ column_names_and_types = self._get_column_names_and_types(self._sql_type_name) - pat = re.compile(r"\s+") - column_names = [col_name for col_name, _, _ in column_names_and_types] - if any(map(pat.search, column_names)): - warnings.warn(_SAFE_NAMES_WARNING, stacklevel=6) - escape = _get_valid_sqlite_name create_tbl_stmts = [ From 5d429b65a5cdc46e340f4cda719cd0228139a149 Mon Sep 17 00:00:00 2001 From: EdAbati Date: Tue, 9 Nov 2021 00:10:05 +0100 Subject: [PATCH 2/2] removed test_safe_names_warning --- pandas/tests/io/test_sql.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pandas/tests/io/test_sql.py b/pandas/tests/io/test_sql.py index 386f11b3dd794..52c1fc51a4c8d 100644 --- a/pandas/tests/io/test_sql.py +++ b/pandas/tests/io/test_sql.py @@ -1366,13 +1366,6 @@ def test_read_sql_delegate(self): with pytest.raises(sql.DatabaseError, match=msg): sql.read_sql("iris", self.conn) - def test_safe_names_warning(self): - # GH 6798 - df = DataFrame([[1, 2], [3, 4]], columns=["a", "b "]) # has a space - # warns on create table with spaces in names - with tm.assert_produces_warning(UserWarning): - sql.to_sql(df, "test_frame3_legacy", self.conn, index=False) - def test_get_schema2(self, test_frame1): # without providing a connection object (available for backwards comp) create_sql = sql.get_schema(test_frame1, "test")