carter
How to store complex strings in the database?
I am learning Elixir so please bear with me. I am trying to figure out how to store complex string into the database. Using an SVG file as an example (because it has a good mix of characters for testing), what is the best way to store it into the database (Postgres/mnesia etc.). I tried converting it into base64, using sigils etc. to no avail. All of them will find some fault with certain characters within the complex string. Is there another way to do this? Thanks in advance.
Most Liked
benwilson512
I would highly recommend storing this SVG information in an actual file, and then calling File.read!("path/to/file.svg"). Giant string literals like this are often a pain to deal with.
lud
What is the tool that you use to write to the database ?
Because once you have your svg string in a variable, you should not have problems with special characters unless you are bulding raw sql like this: "INSERT INTO t VALUES('#{svg}');". This will not work.
But if you use a tool like Ecto, then your variable should fit into a text or binary column.
benwilson512
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #code-sync
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








