Note that there are some explanatory texts on larger screens.

plurals
  1. POPandas DataFrame to SqLite
    primarykey
    data
    text
    <p>I'm learning how to write a pandas dataFrame to SQLite db.</p> <p>I went in one example code:</p> <pre><code>import pandas as pd import pandas.io.sql as pd_sql import sqlite3 as sql con = sql.connect("/home/msalese/Documents/ipyNotebooks/tmp.db") df =pd.DataFrame({'TestData':[1,2,3,4,5,6,7,8,9]}) pd_sql.write_frame(df, "tbldata2", con) </code></pre> <p>But above code rise an exception:</p> <pre><code>--------------------------------------------------------------------------- InterfaceError Traceback (most recent call last) &lt;ipython-input-31-c844f7e3f2e6&gt; in &lt;module&gt;() ----&gt; 1 pd_sql.write_frame(df, "tbldata2", con) /opt/epdFree7.3.2/lib/python2.7/site-packages/pandas-0.10.1-py2.7-linux-x86_64.egg/pandas/io/sql.pyc in write_frame(frame, name, con, flavor, if_exists, **kwargs) 208 if func is None: 209 raise NotImplementedError --&gt; 210 func(frame, name, safe_names, cur) 211 cur.close() 212 con.commit() /opt/epdFree7.3.2/lib/python2.7/site-packages/pandas-0.10.1-py2.7-linux-x86_64.egg/pandas/io/sql.pyc in _write_sqlite(frame, table, names, cur) 219 table, col_names, wildcards) 220 data = [tuple(x) for x in frame.values] --&gt; 221 cur.executemany(insert_query, data) 222 223 def _write_mysql(frame, table, names, cur): InterfaceError: Error binding parameter 0 - probably unsupported type. </code></pre> <p>I think that the problem is on code line 220. If I try :</p> <pre><code>[tuple(x) for x in df.values] </code></pre> <p>the result is:</p> <pre><code>[(1,), (2,), (3,), (4,), (5,), (6,), (7,), (8,), (9,)] </code></pre> <p>may be commas give noise to sqlite db.</p> <p>I'm not sure, can someone give me an hint, please ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload