5 releases (3 breaking)
Uses new Rust 2024
| 0.4.0 | Jul 9, 2025 |
|---|---|
| 0.3.1 | Jun 21, 2025 |
| 0.3.0 | Jun 9, 2025 |
| 0.2.0 | Jun 3, 2025 |
| 0.1.0 | May 25, 2025 |
#1622 in Database interfaces
336 downloads per month
95KB
2K
SLoC
DB Mover
DB Mover is a data moving tool for different databases, aimed at providing the fastest experience.
Install
cargo install db-mover
Usage
db-mover --input "sqlite://input.db" --output "postgres://postgres@localhost/postgres"
Use help for options descriptions
db-mover --help
Features
- PostgreSQL support
- SQLite support
- MySQL / MariaDB support
- Microsoft SQL Server support
- Oracle support
- schema compatibility check
- schema generation
Types conversion
DB Mover ensures schema compatibility by comparing the table schemas from the reader and writer databases. Each supported database type is mapped to a unified DB Mover type. A table is considered compatible if the type mapping from the reader database to the DB Mover type matches the type mapping from the writer database to the same DB Mover type.
Supported types
String- UTF-8–encoded stringBytes- sequence of bytesI64- 64-bit signed integerI32- 32-bit signed integerI16- 16-bit signed integerF64- 64-bit floating-point typeF32- 32-bit floating-point typeDecimal- decimal numberBool- logical value that can be either true or falseTimestamptz- timestamp with time zoneTimestamp- timestamp without time zoneDate- date typeTime- time typeUuid- 128-bit Universally Unique Identifier (UUID)Json- JSON type
PostgreSQL
| PostgreSQL | DB Mover |
|---|---|
| varchar, text, bpchar | String |
| bytea | Bytes |
| bigint, bigserial | I64 |
| integer, serial | I32, I64 |
| smallint, smallserial | I16, I32, I64 |
| double precision | F64 |
| real | F32, F64 |
| decimal, numeric | Decimal |
| boolean | Bool |
| timestamp with time zone | Timestamptz |
| timestamp without time zone | Timestamp |
| date | Date |
| time without time zone | Time |
| UUID | Uuid |
| JSON, JSONB | Json |
MySQL/MariaDB
| Type name (case insensitive) | DB Mover | Comment |
|---|---|---|
| char, varchar, tinytext, text, mediumtext, longtext | String | |
| binary, varbinary, tinyblob, blob, mediumblob, longblob | Bytes | |
| bigint | I64 | |
| integer | I32, I64 | |
| smallint | I16, I32, I64 | |
| double, double precision, real | F64 | |
| float | F32, F64 | |
| decimal, numeric | Decimal | |
| boolean, bool, tinyint(1) | Bool | |
| timestamp | Timestamptz | |
| datetime | Timestamp | |
| date | Date | |
| time | Time | |
| binary(16) | Uuid | Can be disabled with flag --no-mysql-binary-16-as-uuid |
| json, longtext | Json | In MariaDB, a longtext column with a JSON_VALID() constraint is treated as JSON. |
SQLite
SQLite uses dynamic typing, so type mapping is based on the declared column type names. If an actual column value does not match the expected DB Mover type inferred from the column name, an error will be raised.
| SQLite type name (case insensitive) | DB Mover | Comment |
|---|---|---|
| character, varchar*, nvarchar*, char*, nchar*, clob, text, bpchar | String | * - means zero or more chars in type name |
| bytea, blob | Bytes | |
| bigint, bigserial | I64 | |
| integer, serial | I32, I64 | |
| tinyint, smallint, smallserial | I16, I32, I64 | |
| double, double precision | F64 | |
| real, float | F32, F64 | |
| boolean, bool | Bool | |
| timestamptz | Timestamptz | RFC3339 ("YYYY-MM-DD HH:MM:SS.SSS+-HH:MM") |
| timestamp, datetime | Timestamp | ISO 8601 "YYYY-MM-DD HH:MM:SS"/"YYYY-MM-DD HH:MM:SS.SSS" |
| date | Date | "YYYY-MM-DD" |
| time | Time | ISO 8601 time without timezone "HH:MM"/"HH:MM:SS"/"HH:MM:SS.SSS" |
| uuid | Uuid | 4 bytes blob |
| json, jsonb | Json | Rules |
Development
Build
To build executable run:
cargo build --release
Tests
Docker required. After end of tests some containers might be still alive, remove them manually.
Run tests:
cargo test
Run benchmarks:
cargo bench
Pre-commit hooks
Install pre-commit hooks
pre-commit install
Dependencies
~45–63MB
~1M SLoC