如何将 postgres 数据库转换为 sqlite [英] How to convert a postgres database to sqlite

查看:43
本文介绍了如何将 postgres 数据库转换为 sqlite的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一个网站,当我们在本地开发时(其中一个来自 Windows),我们使用 sqlite3,但在服务器(linux)上我们使用 postgres.我们希望能够将生产数据库导入到我们的开发过程中,所以我想知道是否有一种方法可以将 postgres 数据库转储转换为 sqlite3 可以理解的东西(只是将 postgres 的转储 SQL 提供给它很多,许多错误).或者只是在 Windows 上安装 postgres 会更容易吗?谢谢.

解决方案

尽管这里有很多非常有用的答案,但我只想将其标记为已回答.我们最终接受了评论的建议:

<块引用>

我只是将您的开发环境切换到 PostgreSQL,在一个数据库之上开发(尤其是像 SQLite 那样松散和宽容的数据库),但部署在另一个数据库上(尤其是像 PostgreSQL 这样严格的数据库)通常是一种加重和咒骂的方法.——@mu 太短了

<块引用>

为了回应 mu 的回应,不要这样做..不要这样做..不要这样做.在同一件事上开发和部署.否则是糟糕的工程实践.– @Kuberchaun

所以我们刚刚在我们的开发机器上安装了 postgres.上手很容易,工作也很顺利.

We're working on a website, and when we develop locally (one of us from Windows), we use sqlite3, but on the server (linux) we use postgres. We'd like to be able to import the production database into our development process, so I'm wondering if there is a way to convert from a postgres database dump to something sqlite3 can understand (just feeding it the postgres's dumped SQL gave many, many errors). Or would it be easier just to install postgres on windows? Thanks.

解决方案

Even though there are many very good helpful answers here, I just want to mark this as answered. We ended up going with the advice of the comments:

I'd just switch your development environment to PostgreSQL, developing on top of one database (especially one as loose and forgiving as SQLite) but deploying on another (especially one as strict as PostgreSQL) is generally a recipe for aggravation and swearing. – @mu is too short

To echo mu's response, DON'T DO THIS..DON'T DO THIS..DON'T DO THIS. Develop and deploy on the same thing. It's bad engineering practice to do otherwise. – @Kuberchaun

So we just installed postgres on our dev machines. It was easy to get going and worked very smoothly.

这篇关于如何将 postgres 数据库转换为 sqlite的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆