Hi everyone First message to the list. I've been using SQLAlchemy for quite some time, mostly with MySQL and some SQLite. Now, we are moving our DB system to Postgres and I'm converting some scripts that parse data into our databases to Postgres.
I'm having a recurring error on using COPY FROM. The Python code is this <after starting and having a successful connection> curr_path2 = os.getcwd() trans = conn.begin() conn.execute("COPY precursor (spectrum_number, scan_begin, scan_end, mass, mtoz, elution_time_begin, spectral_analysis_id, charge) FROM '%s' " % curr_path2) trans.commit() The error I'm getting, with different input files, sometimes on different lines, is the following: Traceback (most recent call last): File "pp_ipad_parser3.py", line 434, in <module> "FROM '%s' " % curr_path2) File "C:\Python25\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg \sqlalchemy\engine\base.py", line 844, in execute return Connection.executors[c](self, object, multiparams, params) File "C:\Python25\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg \sqlalchemy\engine\base.py", line 854, in _execute_tex t self.__execute_raw(context) File "C:\Python25\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg \sqlalchemy\engine\base.py", line 916, in __execute_ra w self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File "C:\Python25\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg \sqlalchemy\engine\base.py", line 960, in _cursor_exec ute self._handle_dbapi_exception(e, statement, parameters, cursor) File "C:\Python25\lib\site-packages\sqlalchemy-0.4.7p1-py2.5.egg \sqlalchemy\engine\base.py", line 942, in _handle_dbap i_exception raise exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) sqlalchemy.exceptions.DataError: (DataError) missing data for column "spectral_analysis_id" CONTEXT: COPY precursor, line 360: "13177 13177 13177 555.2051 1662.59362792969 64.374" "COPY precursor (spectrum_number, scan_begin, scan_end, mass, mtoz, elution_time_begin, spectral_analysis_id, charge) F ROM 'C:/Users/nuin/workspace/OCBN/src/ipad_parser_1/temp2.csv' " {} The files are tab-delimited ones, and I have checked their integrity and the lines where the errors are occurring are fine. Running the same command by using the -c parameter of psql doesn't give me any errors and the copy finishes successfully. I have searched different forums and web sites trying to find a solution for this problem, but I couldn't find anything that would resemble the error I'm having. I'd like to thank in advance for any help Paulo Nuin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---