Skip to content

Commit a07561e

Browse files
EdAbatijreback
andauthored
CLN: Removed _SAFE_NAMES_WARNING in io.sql (#44361)
* Removed _SAFE_NAMES_WARNING * removed test_safe_names_warning Co-authored-by: Jeff Reback <[email protected]>
1 parent ed7622c commit a07561e

File tree

2 files changed

+0
-19
lines changed

2 files changed

+0
-19
lines changed

pandas/io/sql.py

-12
Original file line numberDiff line numberDiff line change
@@ -1818,12 +1818,6 @@ def _get_valid_sqlite_name(name):
18181818
return '"' + uname.replace('"', '""') + '"'
18191819

18201820

1821-
_SAFE_NAMES_WARNING = (
1822-
"The spaces in these column names will not be changed. "
1823-
"In pandas versions < 0.14, spaces were converted to underscores."
1824-
)
1825-
1826-
18271821
class SQLiteTable(SQLTable):
18281822
"""
18291823
Patch the SQLTable for fallback support.
@@ -1883,12 +1877,6 @@ def _create_table_setup(self):
18831877
statement while the rest will be CREATE INDEX statements.
18841878
"""
18851879
column_names_and_types = self._get_column_names_and_types(self._sql_type_name)
1886-
1887-
pat = re.compile(r"\s+")
1888-
column_names = [col_name for col_name, _, _ in column_names_and_types]
1889-
if any(map(pat.search, column_names)):
1890-
warnings.warn(_SAFE_NAMES_WARNING, stacklevel=find_stack_level())
1891-
18921880
escape = _get_valid_sqlite_name
18931881

18941882
create_tbl_stmts = [

pandas/tests/io/test_sql.py

-7
Original file line numberDiff line numberDiff line change
@@ -1366,13 +1366,6 @@ def test_read_sql_delegate(self):
13661366
with pytest.raises(sql.DatabaseError, match=msg):
13671367
sql.read_sql("iris", self.conn)
13681368

1369-
def test_safe_names_warning(self):
1370-
# GH 6798
1371-
df = DataFrame([[1, 2], [3, 4]], columns=["a", "b "]) # has a space
1372-
# warns on create table with spaces in names
1373-
with tm.assert_produces_warning(UserWarning):
1374-
sql.to_sql(df, "test_frame3_legacy", self.conn, index=False)
1375-
13761369
def test_get_schema2(self, test_frame1):
13771370
# without providing a connection object (available for backwards comp)
13781371
create_sql = sql.get_schema(test_frame1, "test")

0 commit comments

Comments
 (0)