@@ -142,6 +142,7 @@ defmodule Exqlite.Connection do
142
142
* `:soft_heap_limit` - The size limit in bytes for the heap limit.
143
143
* `:hard_heap_limit` - The size limit in bytes for the heap.
144
144
* `: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.
145
146
* `:load_extensions` - A list of paths identifying extensions to load. Defaults to `[]`.
146
147
The provided list will be merged with the global extensions list, set on `:exqlite, :load_extensions`.
147
148
Be aware that the path should handle pointing to a library compiled for the current architecture.
@@ -510,6 +511,13 @@ defmodule Exqlite.Connection do
510
511
set_pragma ( db , "busy_timeout" , Pragma . busy_timeout ( options ) )
511
512
end
512
513
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
+
513
521
defp load_extensions ( db , options ) do
514
522
global_extensions = Application . get_env ( :exqlite , :load_extensions , [ ] )
515
523
@@ -555,7 +563,8 @@ defmodule Exqlite.Connection do
555
563
:ok <- set_journal_size_limit ( db , options ) ,
556
564
:ok <- set_soft_heap_limit ( db , options ) ,
557
565
: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
559
568
state = % __MODULE__ {
560
569
db: db ,
561
570
default_transaction_mode:
0 commit comments