@@ -142,6 +142,7 @@ defmodule Exqlite.Connection do
142142 * `:soft_heap_limit` - The size limit in bytes for the heap limit.
143143 * `:hard_heap_limit` - The size limit in bytes for the heap.
144144 * `:custom_pragmas` - A list of custom pragmas to set on the connection, for example to configure extensions.
145+ * `:serialized` - A SQLite database which was previously serialized, to load into the database after connection.
145146 * `:load_extensions` - A list of paths identifying extensions to load. Defaults to `[]`.
146147 The provided list will be merged with the global extensions list, set on `:exqlite, :load_extensions`.
147148 Be aware that the path should handle pointing to a library compiled for the current architecture.
@@ -510,6 +511,13 @@ defmodule Exqlite.Connection do
510511 set_pragma ( db , "busy_timeout" , Pragma . busy_timeout ( options ) )
511512 end
512513
514+ defp deserialize ( db , options ) do
515+ case Keyword . get ( options , :serialized , nil ) do
516+ nil -> :ok
517+ serialized -> Sqlite3 . deserialize ( db , serialized )
518+ end
519+ end
520+
513521 defp load_extensions ( db , options ) do
514522 global_extensions = Application . get_env ( :exqlite , :load_extensions , [ ] )
515523
@@ -555,7 +563,8 @@ defmodule Exqlite.Connection do
555563 :ok <- set_journal_size_limit ( db , options ) ,
556564 :ok <- set_soft_heap_limit ( db , options ) ,
557565 :ok <- set_hard_heap_limit ( db , options ) ,
558- :ok <- load_extensions ( db , options ) do
566+ :ok <- load_extensions ( db , options ) ,
567+ :ok <- deserialize ( db , options ) do
559568 state = % __MODULE__ {
560569 db: db ,
561570 default_transaction_mode:
0 commit comments