python - pandas handle NaN/None inserts into sybase -


is there working solution insert nan/none values pandas dataframe sybase-ase tables?

i tried suggested solution after researching online (for pandas side): df.where(pd.notnull(df), none)

however, when try insert sybase-ase using bulk_copy/bcp, none gets inserted 'nan.0' reason.

any ideas why happen or knows of workaround accomplish these insertions of nan/none null sybase? [sybase supports null]


full stacktrace databaseerror:

df.to_sql('test_table', engine, if_exists='append', index=false, chunksize=1)  traceback (most recent call last):   file "<stdin>", line 1, in <module>   file "/7ff6xgw24wvny74gfgzcvf6p88vc6k1a-pandas-0.15.2-16/lib/pandas/core/generic.py", line 966, in to_sql     dtype=dtype)   file "/7ff6xgw24wvny74gfgzcvf6p88vc6k1a-pandas-0.15.2-16/lib/pandas/io/sql.py", line 538, in to_sql     chunksize=chunksize, dtype=dtype)   file "/7ff6xgw24wvny74gfgzcvf6p88vc6k1a-pandas-0.15.2-16/lib/pandas/io/sql.py", line 1172, in to_sql     table.insert(chunksize)   file "/7ff6xgw24wvny74gfgzcvf6p88vc6k1a-pandas-0.15.2-16/lib/pandas/io/sql.py", line 717, in insert     self._execute_insert(conn, keys, chunk_iter)   file "/7ff6xgw24wvny74gfgzcvf6p88vc6k1a-pandas-0.15.2-16/lib/pandas/io/sql.py", line 692, in _execute_insert     conn.execute(self.insert_statement(), data)   file "/6rr1fqx3n9i93camwqhpfvylis5knyxh-python-sqlalchemy-0.7.9/lib/python2.7/site-packages/sqlalchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1449, in execute     params)   file "/6rr1fqx3n9i93camwqhpfvylis5knyxh-python-sqlalchemy-0.7.9/lib/python2.7/site-packages/sqlalchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1584, in _execute_clauseelement     compiled_sql, distilled_params   file "/6rr1fqx3n9i93camwqhpfvylis5knyxh-python-sqlalchemy-0.7.9/lib/python2.7/site-packages/sqlalchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1698, in _execute_context     context)   file "/6rr1fqx3n9i93camwqhpfvylis5knyxh-python-sqlalchemy-0.7.9/lib/python2.7/site-packages/sqlalchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/engine/base.py", line 1691, in _execute_context     context)   file "/6rr1fqx3n9i93camwqhpfvylis5knyxh-python-sqlalchemy-0.7.9/lib/python2.7/site-packages/sqlalchemy-0.7.9-py2.7-linux-x86_64.egg/sqlalchemy/engine/default.py", line 331, in do_execute     cursor.execute(statement, parameters)   file "/six2r9cj6gx8yhdpjygflakgnxyjxj2y-sybase-15.0-jump1.00-3/lib-python/sybase.py", line 546, in execute     self._start()   file "/six2r9cj6gx8yhdpjygflakgnxyjxj2y-sybase-15.0-jump1.00-3/lib-python/sybase.py", line 695, in _start     return self._mainloop()   file "/six2r9cj6gx8yhdpjygflakgnxyjxj2y-sybase-15.0-jump1.00-3/lib-python/sybase.py", line 709, in _mainloop     self._raise_error(e)   file "/six2r9cj6gx8yhdpjygflakgnxyjxj2y-sybase-15.0-jump1.00-3/lib-python/sybase.py", line 753, in _raise_error     raise exc sqlalchemy.exc.databaseerror: (databaseerror) msg 102, level 15, state 181, line 1 incorrect syntax near ','.  'insert test_table ("token", "assettoken", "instrumentname", "symbol", "series", "reserved1", "expirydate", "strikeprice", "optiontype", "category", "calevel", "reservedidentifier", "permittedtotrade", "issuerate", "securitystatusa", "eligibilitya", "reserveda", "securitystatusb", "eligibilityb", "reservedb", "securitystatusc", "eligibilityc", "reservedc", "securitystatusd", "eligibilityd", "reservedd", "issuestartdate", "interestpaymentdate", "issuematuritydate", "marginpercentage", "minimumlotquantity", "boardlotquantity", "ticksize", "issuedcapital", "freezequantity", "warningquantity", "listingdate", "expulsiondate", "readmissiondate", "recorddate", "nodeliverystartdate", "nodeliveryenddate", "lowpricerange", "highpricerange", "exdate", "bookclosurestartdate", "bookclosureenddate", "localldbupdatedatetime", "exercisestartdate", "exerciseenddate", "tickerselection", "oldtokennumber", "creditrating", "name", "egmagm", "interestdivident", "rightsbonus", "mfaon", "remarks", "exstyle", "exallowed", "exrejectionallowed", "plallowed", "checksum", "iscorporateadjusted", "symbolforasset", "instrumentofasset", "baseprice", "deleteflag") values (@token, @assettoken, @instrumentname, @symbol, @series, @reserved1, @expirydate, @strikeprice, @optiontype, @category, @calevel, @reservedidentifier, @permittedtotrade, @issuerate, @securitystatusa, @eligibilitya, @reserveda, @securitystatusb, @eligibilityb, @reservedb, @securitystatusc, @eligibilityc, @reservedc, @securitystatusd, @eligibilityd, @reservedd, @issuestartdate, @interestpaymentdate, @issuematuritydate, @marginpercentage, @minimumlotquantity, @boardlotquantity, @ticksize, @issuedcapital, @freezequantity, @warningquantity, @listingdate, @expulsiondate, @readmissiondate, @recorddate, @nodeliverystartdate, @nodeliveryenddate, @lowpricerange, @highpricerange, @exdate, @bookclosurestartdate, @bookclosureenddate, @localldbupdatedatetime, @exercisestartdate, @exerciseenddate, @tickerselection, @oldtokennumber, @creditrating, @name, @egmagm, @interestdivident, @rightsbonus, @mfaon, @remarks, @exstyle, @exallowed, @exrejectionallowed, @plallowed, @checksum, @iscorporateadjusted, @symbolforasset, @instrumentofasset, @baseprice, @deleteflag)' {'@interestpaymentdate': 0, '@warningquantity': 0.0, '@issuerate': 0, '@exstyle': 'e', '@iscorporateadjusted': 'n', '@bookclosurestartdate': 0, '@baseprice': 242030, '@exercisestartdate': 1127520000, '@optiontype': 'ce', '@bookclosureenddate': 0, '@egmagm': 0, '@oldtokennumber': 1, '@exallowed': 'n', '@issuestartdate': 1120003200, '@exrejectionallowed': 'n', '@issuedcapital': 999999999999.0, '@token': 35000, '@readmissiondate': 0, '@lowpricerange': 144550, '@deleteflag': 'n', '@reserved1': none, '@category': 1, '@reservedd': none, '@reservedb': none, '@reservedc': none, '@reserveda': none, '@ticksize': 5, '@nodeliveryenddate': 0, '@boardlotquantity': 25, '@symbol': 'banknifty', '@remarks': none, '@symbolforasset': none, '@name': 'banknifty15sep16800ce', '@freezequantity': 2501.0, '@checksum': none, '@localldbupdatedatetime': 1121272656, '@minimumlotquantity': 25, '@permittedtotrade': 0, '@expirydate': 1127572200, '@nodeliverystartdate': 0, '@expulsiondate': 0, '@listingdate': 1120003200, '@instrumentname': 'optidx', '@instrumentofasset': none, '@exdate': 0, '@issuematuritydate': 1127572200, '@exerciseenddate': 1127572200, '@calevel': 0, '@interestdivident': 0, '@recorddate': 0, '@marginpercentage': 0, '@eligibilityd': 0, '@eligibilitya': 1, '@eligibilityb': 0, '@eligibilityc': 0, '@series': 'xx', '@assettoken': 26009, '@mfaon': 0, '@securitystatusa': 1, '@securitystatusb': 2, '@securitystatusc': 2, '@securitystatusd': 3, '@highpricerange': 339510, '@strikeprice': 1680000, '@creditrating': none, '@rightsbonus': 0, '@reservedidentifier': 0, '@tickerselection': 15, '@plallowed': 'n'} 


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -