@@ -834,7 +834,11 @@ def _create_table_setup(self):
834
834
for name , typ , is_index in column_names_and_types ]
835
835
836
836
if self .keys is not None :
837
- pkc = PrimaryKeyConstraint (self .keys , name = self .name + '_pk' )
837
+ if not com .is_list_like (self .keys ):
838
+ keys = [self .keys ]
839
+ else :
840
+ keys = self .keys
841
+ pkc = PrimaryKeyConstraint (* keys , name = self .name + '_pk' )
838
842
columns .append (pkc )
839
843
840
844
schema = self .schema or self .pd_sql .meta .schema
@@ -899,8 +903,8 @@ def _harmonize_columns(self, parse_dates=None):
899
903
900
904
def _get_notnull_col_dtype (self , col ):
901
905
"""
902
- Infer datatype of the Series col. In case the dtype of col is 'object'
903
- and it contains NA values, this infers the datatype of the not-NA
906
+ Infer datatype of the Series col. In case the dtype of col is 'object'
907
+ and it contains NA values, this infers the datatype of the not-NA
904
908
values. Needed for inserting typed data containing NULLs, GH8778.
905
909
"""
906
910
col_for_inference = col
@@ -1272,7 +1276,7 @@ def _get_unicode_name(name):
1272
1276
return uname
1273
1277
1274
1278
def _get_valid_mysql_name (name ):
1275
- # Filter for unquoted identifiers
1279
+ # Filter for unquoted identifiers
1276
1280
# See http://dev.mysql.com/doc/refman/5.0/en/identifiers.html
1277
1281
uname = _get_unicode_name (name )
1278
1282
if not len (uname ):
@@ -1293,7 +1297,7 @@ def _get_valid_sqlite_name(name):
1293
1297
# Ensure the string does not include any NUL characters.
1294
1298
# Replace all " with "".
1295
1299
# Wrap the entire thing in double quotes.
1296
-
1300
+
1297
1301
uname = _get_unicode_name (name )
1298
1302
if not len (uname ):
1299
1303
raise ValueError ("Empty table or column name specified" )
@@ -1377,7 +1381,11 @@ def _create_table_setup(self):
1377
1381
for cname , ctype , _ in column_names_and_types ]
1378
1382
1379
1383
if self .keys is not None and len (self .keys ):
1380
- cnames_br = "," .join ([escape (c ) for c in self .keys ])
1384
+ if not com .is_list_like (self .keys ):
1385
+ keys = [self .keys ]
1386
+ else :
1387
+ keys = self .keys
1388
+ cnames_br = ", " .join ([escape (c ) for c in keys ])
1381
1389
create_tbl_stmts .append (
1382
1390
"CONSTRAINT {tbl}_pk PRIMARY KEY ({cnames_br})" .format (
1383
1391
tbl = self .name , cnames_br = cnames_br ))
@@ -1391,7 +1399,7 @@ def _create_table_setup(self):
1391
1399
cnames = "_" .join (ix_cols )
1392
1400
cnames_br = "," .join ([escape (c ) for c in ix_cols ])
1393
1401
create_stmts .append (
1394
- "CREATE INDEX " + escape ("ix_" + self .name + "_" + cnames ) +
1402
+ "CREATE INDEX " + escape ("ix_" + self .name + "_" + cnames ) +
1395
1403
"ON " + escape (self .name ) + " (" + cnames_br + ")" )
1396
1404
1397
1405
return create_stmts
@@ -1416,7 +1424,7 @@ def _sql_type_name(self, col):
1416
1424
1417
1425
elif col_type == "complex" :
1418
1426
raise ValueError ('Complex datatypes not supported' )
1419
-
1427
+
1420
1428
if col_type not in _SQL_TYPES :
1421
1429
col_type = "string"
1422
1430
0 commit comments