So I was thinking that someone could help me
I currently have some classes < / P>
square is 1 (column): pass @compiles (Sha1) def compile_sha1 (element, compiler, ** kw): return 'password ("{}")' '. Format (element.name) And when I use SQLAlchemy orm to insert a column, I can pass the attribute as Sha1 (value) and Let me do it. However for testing purposes we load something in our database in a database such as
insert = model.__ table __. Insert (value) session.execute (insert) To overlumber the way a SQL is generated for a specific model, there is a way in the semicolon, so that < Use (UUID, Password) value (UUID, password (password :)) to enter in the pre> model (UUID, Password) value (UUID) Model To do
Any thoughts?
A new feature that allows it to be called bind_expression () If I understand correctly, then you probably want to accept your arbitrary element in your code, you do not need to explicitly call Sha1 , And in this case the argument will always be a BindParam : from the sqlalchemy.sql.expression column can be imported column from sqlalchemy.ext.compiler import class Shay 1 (column element): def __ Init__ (self, arg): self.arg = arg = compiles (Sha1) def compile_sha1 (element, compiler, ** kw): return 'password (% s)'% compiler.process (element.arg, ** kw) Class Sha1Type (TypeDecorator): impl = String def bind_expression (return, bindview): Return Sha1 (bindvalue) m = metadata () T = table ('mytable', column ('id', integer, primary_key = true), column ( 'Password', ink type)) print tee .inert () print tee .inert (). Value (password = 'some password')
No comments:
Post a Comment