Repository: pandas-dev/pandas

Issue:
test_integer_col_names: compatibility with wheezy sqlalchemy?
```
======================================================================
ERROR: test_integer_col_names (pandas.io.tests.test_sql.TestSQLApi)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/buildslave/nd-bb-slave-sparc-wheezy/pandas-py2_7-wheezy-sparc/build/venv/lib/python2.7/site-packages/pandas-0.14.0_45_g1754bb5-py2.7-linux-sparc64.egg/pandas/io/tests/test_sql.py", line 561, in test_integer_col_names
    if_exists='replace')
  File "/home/buildslave/nd-bb-slave-sparc-wheezy/pandas-py2_7-wheezy-sparc/build/venv/lib/python2.7/site-packages/pandas-0.14.0_45_g1754bb5-py2.7-linux-sparc64.egg/pandas/io/sql.py", line 440, in to_sql
    index_label=index_label)
  File "/home/buildslave/nd-bb-slave-sparc-wheezy/pandas-py2_7-wheezy-sparc/build/venv/lib/python2.7/site-packages/pandas-0.14.0_45_g1754bb5-py2.7-linux-sparc64.egg/pandas/io/sql.py", line 815, in to_sql
    table.insert()
  File "/home/buildslave/nd-bb-slave-sparc-wheezy/pandas-py2_7-wheezy-sparc/build/venv/lib/python2.7/site-packages/pandas-0.14.0_45_g1754bb5-py2.7-linux-sparc64.egg/pandas/io/sql.py", line 584, in insert
    self.pd_sql.execute(ins, data_list)
  File "/home/buildslave/nd-bb-slave-sparc-wheezy/pandas-py2_7-wheezy-sparc/build/venv/lib/python2.7/site-packages/pandas-0.14.0_45_g1754bb5-py2.7-linux-sparc64.egg/pandas/io/sql.py", line 783, in execute
    return self.engine.execute(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 2447, in execute
    return connection.execute(statement, *multiparams, **params)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1449, in execute
    params)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 1576, in _execute_clauseelement
    inline=len(distilled_params) > 1)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/expression.py", line 1778, in compile
    return self._compiler(dialect, bind=bind, **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/expression.py", line 1784, in _compiler
    return dialect.statement_compiler(dialect, self, **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 277, in __init__
    engine.Compiled.__init__(self, dialect, statement, **kwargs)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 705, in __init__
    self.string = self.process(self.statement)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/engine/base.py", line 724, in process
    return obj._compiler_dispatch(self, **kwargs)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/visitors.py", line 72, in _compiler_dispatch
    return getter(visitor)(self, **kw)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 1047, in visit_insert
    colparams = self._get_colparams(insert_stmt)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 1243, in _get_colparams
    for key in self.column_keys
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/compiler.py", line 1245, in <genexpr>
    key not in stmt.parameters)
  File "/usr/lib/python2.7/dist-packages/sqlalchemy/sql/expression.py", line 1396, in _column_as_key
    return element.key
AttributeError: 'long' object has no attribute 'key'
```

http://nipy.bic.berkeley.edu/builders/pandas-py2.7-wheezy-sparc/builds/193/steps/shell_7/logs/stdio

```
INSTALLED VERSIONS
------------------
commit: None
python: 2.7.3.final.0
python-bits: 32
OS: Linux
OS-release: 2.6.32-5-sparc64-smp
machine: sparc64
processor: 
byteorder: big
LC_ALL: None
LANG: None

pandas: 0.14.0-45-g1754bb5
nose: 1.1.2
Cython: 0.19
numpy: 1.6.2
scipy: 0.10.1
statsmodels: 0.5.0
IPython: 0.13.1
sphinx: 1.1.3
patsy: 0.2.1
scikits.timeseries: None
dateutil: 1.5
pytz: 2012c
bottleneck: None
tables: 2.3.1
numexpr: 2.0.1
matplotlib: 1.1.1rc2
openpyxl: 1.7.0
xlrd: 0.6.1
xlwt: 0.7.4
xlsxwriter: None
lxml: 2.3.2
bs4: 4.1.0
html5lib: 0.95-dev
bq: None
apiclient: None
rpy2: 2.2.6
sqlalchemy: 0.7.8
pymysql: None
psycopg2: None
```



Discussion:
Related to #6340 and #7022. We saw the same error there.


Resolving patch:
diff --git a/pandas/io/sql.py b/pandas/io/sql.py
--- a/pandas/io/sql.py
+++ b/pandas/io/sql.py
@@ -567,7 +567,7 @@ def insert(self):
         ins = self.insert_statement()
         data_list = []
         temp = self.insert_data()
-        keys = temp.columns
+        keys = list(map(str, temp.columns))
 
         for t in temp.itertuples():
             data = dict((k, self.maybe_asscalar(v))


Test patch: