A set of Pocketbase command-line hooks to enable data import directly into your Pocketbase project's database.
Import an existing text file containing records in a delimited format into a new collection in your current Pocketbase project. The file must have a single header record containing the field names for each row in the file.
The file is parsed and analyzed to determine an appropriate data type for each field, then the collection is created, and then data is loaded into the collection.
pocketbase serve
if it's not already running
pocketbase serve --http 0.0.0.0:8090
import_csv.pb.js
into the pb_hooks
folder of your project
pb_hooks
folder first if it doesn't exist)import_csv <path_to_file> <collection_name>
pocketbase import_csv myfile.csv mycollection
pocketbase import_csv ~/path/to/myfile.csv mycollection
pocketbase import_csv myfile.tsv mycollection
pocketbase import_csv myfile.txt mycollection
Import an existing SQLite database on disk into the current Pocketbase project. You can import all the tables in the external database (the default) or provide an optional list of tables to be imported. One collection is created for each table using very basic data types, then data is imported from the external SQLite database into your Pocketbase database (pb_data/data.db
).
pocketbase serve
if it's not already running
pocketbase serve --http 0.0.0.0:8090
import_sqlite.pb.js
into the pb_hooks
folder of your project
pb_hooks
folder first if it doesn't exist)import_sqlite <externalDB> [table_list]
Import all the tables in my SQLite database:
pocketbase import_sqlite /Users/myusername/externalDB.sqlite
Import just the tables named people
and places
from my database:
pocketbase import_sqlite /Users/myusername/externalDB.sqlite "'people','places'"
insert into table (fields) select (fields) from external_database.table
.numeric
and CHAR and VARCHAR types to text
.-1
and any null text fields to an empty string ''
.