![]() In the next part, we'll look at writing a simple query object, which will help use write safe dynamic SQL while staying relatively close to raw SQL. You should personalize and optimize this to fit your needs. You should keep in mind that this is only meant as a base template. ) end end, ) # optional parameters to pass to Postgrex affected! (tx, "update users set status = 'deleted' where id = $1", ) = 1 do DB. ![]() Which we can then use like so: alias MyApp. Let's look at a basic example: defmodule MyApp do use Application def start (_type, _args ) do # Probably want to store this in a config # and load via Application.fetch_env!(:myapp, :db)ĭb_config = Ĭhildren = [ -> raise "transaction! rollback" Right now I have to use raw SQL query with which is of course far from optimal (BTW is there a way to manually escape a value for such raw SQL usage). Use Postgrex.query/4, Postgrex.query!/4 and ansaction/3 TBH I didnt, this is my first try, was referring to this answer on Elixir Forum by OvermindDL1.Use Postgrex.start_link to start a named connection process, probably as part of your root/application supervisor. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |