hi guys, recently I meet a strange error when i use sqlalchemy to insert 
data into a table of mysql.

Traceback (most recent call last):

  File "C:\Program 
Files\Python35\lib\site-packages\sqlalchemy\engine\base.py", line 1127, in 
_execute_context

    context = constructor(dialect, self, conn, *args)

  File "C:\Program 
Files\Python35\lib\site-packages\sqlalchemy\engine\default.py", line 694, 
in _init_compiled

    for key in compiled_params

  File "C:\Program 
Files\Python35\lib\site-packages\sqlalchemy\engine\default.py", line 694, 
in <genexpr>

    for key in compiled_params

  File "C:\Program 
Files\Python35\lib\site-packages\sqlalchemy\sql\sqltypes.py", line 877, in 
process

    return DBAPIBinary(value)

  File "C:\Program Files\Python35\lib\site-packages\pymysql\__init__.py", 
line 85, in Binary

    return bytes(x)

TypeError: string argument without an encoding



It seems that the the value of the variable processors in module 
sqlalchemy\engine\default.py 
line 690 has some problem


                    param = dict(

                        (

                            key,

                            processors[key](compiled_params[key])

                            if key in processors

                            else compiled_params[key]

                        )

                        for key in compiled_params

                    )



and the variable processsors was assigned at line 652 to equal to compiled.
_bind_processors 




when I try to find out the cause of the error, I find an interesting 
appearance that if I watch the variable in debug mode or add the expression 
(in red color)


        if statement is not None:

            self.statement = statement

            self.can_execute = statement.supports_execution

            if self.can_execute:

                self.execution_options = statement._execution_options

            self._bind_processors = self._bind_processors

            self.string = self.process(self.statement, **compile_kwargs)


into the module sqlchemy/sql/compiler.py at line 219, the error will not 
occur.


In fact, if I add any expression about self._bind_processors, for example 


        print(self._bind_processors)


before calling the self.process method, the error will always disappear.


I guess there may be some bug here. 


-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to