Skip to content

Commit c4a996a

Browse files
Merge pull request #9411 from dashesy/add_sql_test
test sql table name
2 parents 43c1007 + 2c5b2c6 commit c4a996a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

doc/source/io.rst

+2-1
Original file line numberDiff line numberDiff line change
@@ -3368,7 +3368,8 @@ The key functions are:
33683368
The function :func:`~pandas.read_sql` is a convenience wrapper around
33693369
:func:`~pandas.read_sql_table` and :func:`~pandas.read_sql_query` (and for
33703370
backward compatibility) and will delegate to specific function depending on
3371-
the provided input (database table name or sql query).
3371+
the provided input (database table name or sql query).
3372+
Table names do not need to be quoted if they have special characters.
33723373

33733374
In the following example, we use the `SQlite <http://www.sqlite.org/>`__ SQL database
33743375
engine. You can use a temporary SQLite database where data are stored in

pandas/io/tests/test_sql.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
- Tests for the public API (only tests with sqlite3)
77
- `_TestSQLApi` base class
88
- `TestSQLApi`: test the public API with sqlalchemy engine
9-
- `TesySQLiteFallbackApi`: test the public API with a sqlite DBAPI connection
9+
- `TestSQLiteFallbackApi`: test the public API with a sqlite DBAPI connection
1010
- Tests for the different SQL flavors (flavor specific type conversions)
1111
- Tests for the sqlalchemy mode: `_TestSQLAlchemy` is the base class with
1212
common methods, the different tested flavors (sqlite3, MySQL, PostgreSQL)
@@ -1676,13 +1676,14 @@ def test_illegal_names(self):
16761676
flavor=self.flavor)
16771677

16781678
for ndx, weird_name in enumerate(['test_weird_name]','test_weird_name[',
1679-
'test_weird_name`','test_weird_name"', 'test_weird_name\'']):
1679+
'test_weird_name`','test_weird_name"', 'test_weird_name\'',
1680+
'_b.test_weird_name_01-30', '"_b.test_weird_name_01-30"']):
16801681
df.to_sql(weird_name, self.conn, flavor=self.flavor)
16811682
sql.table_exists(weird_name, self.conn)
16821683

16831684
df2 = DataFrame([[1, 2], [3, 4]], columns=['a', weird_name])
16841685
c_tbl = 'test_weird_col_name%d'%ndx
1685-
df.to_sql(c_tbl, self.conn, flavor=self.flavor)
1686+
df2.to_sql(c_tbl, self.conn, flavor=self.flavor)
16861687
sql.table_exists(c_tbl, self.conn)
16871688

16881689

0 commit comments

Comments
 (0)