SQLite is an excellent embedded database, often used in mobile terminal, internal or temporary database, embedded devices and the Internet of Things and other scenarios. It occupies very low resources, may only need a few hundred K of memory enough, is a true open source unlimited database, cross-platform, support Linux, Mac, Android, IOS and Windows systems, mainly used for embedded development.

At present, SQLite is used by a large number of users. Most mobile terminals are equipped with SQLite database, including popular applications such as WeChat and Meituan that we are familiar with. An application can also use SQLite in the initial version stage to quickly build the prototype. With the gradual increase of data volume in continuous operation, the business becomes more and more complex. Some shortcomings of SQLite have also been exposed, including unsuitable for large data storage, unable to meet the high concurrency and sharing of multi-threads, and lack of user management and security functions. At this point, you need to migrate your application to a C/S structured database management system (MySQL, PostgreSQL, Oracle, SQL Server) and synchronize your historical data.

SQLitetopostgres is a powerful database conversion software, which supports the conversion of SQLite database to Postgres type. The software provides a wizard configuration process, and supports the import and export of the database or the database conversion operation of custom fields. It is a very convenient data migration tool.

The preparatory work

Talk is cheap, show me the code. Next, let’s personally experience our preparation work as follows:

  • A SQLite database file, we use the Golang program to generate

    package main import ( "database/sql" "fmt" _ "github.com/mattn/go-sqlite3" ) func main() { db, err := sql.Open("sqlite3", "./foo.db") checkErr(err) sql_table := ` CREATE TABLE IF NOT EXISTS "userinfo" ( "uid" INTEGER PRIMARY KEY AUTOINCREMENT, "username" VARCHAR(64) NULL, "departname" VARCHAR(64) NULL, "created" TIMESTAMP default (datetime('now', 'localtime')) ); '_, err = db.exec (SQL_TABLE)// INSERT data INTO table STMT, err := db.prepare ("INSERT INTO userinfo(username, id, id, id, id, id); departname, created) values(? ,? ,?) Exec("astaxie", "R&D department ", "2012-12-09") checkErr(err) id, Err := res.lastInsertid () checkErr(err) fmt.println (id) // update data STMT, err = db.prepare ("update userinfo set username=? where uid=?" ) checkErr(err) res, err = stmt.Exec("astaxieupdate", id) checkErr(err) affect, Err := res.rowsaffected () Checkerr (Err) fmt.println (affect); err := db.Query("SELECT * FROM userinfo") checkErr(err) for rows.Next() { var uid int var username string var department  string var created string err = rows.Scan(&uid, &username, &department, &created) checkErr(err) fmt.Println(uid) fmt.Println(username) fmt.Println(department) fmt.Println(created) } db.Close()  } func checkErr(err error) { if err ! = nil { panic(err) } }
    go mod init tttt
    go mod tidy
    rm -rf ~/.cache/go-build/* 
    yum install binutils
    go build main.go
  • A PostgreSQL database service, I’m using a free digital PostgreSQL database service here: MemfireDB, which runs on the public cloud and is accessible by one-click registration without having to deploy it yourself.
  • SqliteToPostgres program, download address https://www.crsky.com/soft/21…

Open to the

SQLiteToCostgres is very simple. Once installed and started, you just need to follow the wizard step by step

The first step is to select the SQLite file you want to migrate and click “OK”, or to verify that the file is corrupted, click “Connect” to test, showing “Connected” to indicate that the file is intact

Step 2: Log in MemfireDB to get the service address, user name and database name, and click “Connect” to test. “Connected” indicates that the service connection is normal, and we click “OK” to proceed to the next step

The third step is to Select the Tables to Import. Here, Select “Import All Tables” and “Select All” to Import All Tables. Click “Next” for the remaining steps

Finally, when the import is complete, log in to MemfireDB to view the data we imported

Thanks

SQLitetopostgres is a powerful and convenient software. The fool-like operation allows us to quickly import the data from SQLite into PostgreSQL, which can achieve twice the result with half the effort in data backup and application migration.