Live data from Hacker News

MySQL to PostgreSQL converter

github.com

31–37 of 37 posts

Re: MySQL to PostgreSQL converter

#31

Earlier quoted context omitted.

Yeah, seems like postgres is the only database that doesn't support those things. I mean, I use postgres, but I curse the lack of this feature regularly.

Which other databases support "insert ignore"?

while not that specific syntax, upserts are widely supported. e.g. http://en.wikipedia.org/wiki/Merge_%28SQL%29

I think PostgreSQL is relatively alone in lacking it.

Re: MySQL to PostgreSQL converter

#32
post #31

Earlier quoted context omitted.

Which other databases support "insert ignore"?

while not that specific syntax, upserts are widely supported. e.g. http://en.wikipedia.org/wiki/Merge_%28SQL%29 I think PostgreSQL is relatively alone in lacking it.

got it, thanks mh-!

Re: MySQL to PostgreSQL converter

#33
post #7

Earlier quoted context omitted.

Ah. That's a relief, I was a little worried. But that makes it strange that someone, knowing of this limitation, would choose to start with the xml dump format.

I think the fact that this form of dump doesn't contain foreign keys is even more extraordinary. What's the point of having a dump format that you can't use to restore your database properly? Does it have a health warning advising that it's not a proper dump?

Well, I've had issues with pg_dump's standard format. It can't be directly used to restore a db, one must manually set it to dump a .bak or something else.

Re: MySQL to PostgreSQL converter

#34
post #31

Earlier quoted context omitted.

Which other databases support "insert ignore"?

while not that specific syntax, upserts are widely supported. e.g. http://en.wikipedia.org/wiki/Merge_%28SQL%29 I think PostgreSQL is relatively alone in lacking it.

I have tried to read into why PostgresSQL doesn't yet (they are working it) have upserts. Several times I have come across people discussing that Merge which is much more powerful the simple upserts, also doesn't really mandate the nature of upserts in most databases.

Simply a user might expect that upserts always succeed with either an update or insert, and never return an error (except when the consistency model is set high enough).

The problem is that many implementations of merge doesn't provide that guarantee, unbeknownst to many users. Or they are simpler databases such as sqlite (which doesn't provide the same multi-user/transaction performance). Postgres, as they are well known for, want to implement it properly. They know that application developers does not expect that they have to resubmit failed upsert. Aside: they are also working on audit features, which presents a number of implementations difficulties that upserts also does. So some time or later, probably not to far away, we will see upserts in postgres. Proper atomic, performant, nice upserts.

Re: MySQL to PostgreSQL converter

#36
post #33
post #7

Earlier quoted context omitted.

I think the fact that this form of dump doesn't contain foreign keys is even more extraordinary. What's the point of having a dump format that you can't use to restore your database properly? Does it have a health warning advising that it's not a proper dump?

Well, I've had issues with pg_dump's standard format. It can't be directly used to restore a db, one must manually set it to dump a .bak or something else.

Not sure what you refer to here. All pg_dump formats should work for restoring a database. The only flaw in pg_dump that I know of is the mess if you want to dump an entire cluster of databases but still have one file per database.

Re: MySQL to PostgreSQL converter

#37
post #8

I would recommend using pgloader ( http://pgloader.io/ ) instead. It is simple to use in the default case, but can be configured with rules for how data types should be converted if necessary. It can also clean up weird timestamps like 0000-00-00 00:00:00.

Upvote for pgloader. Moving data from SQL Server into Postgres with PGLoader has been fairly seamless and the maintainer is very responsive on Github.

Nice to hear that it works so well already. It is a very new feature which was sponsored by the company I work for only a couple of months ago. We are not even done migrating our database yet (we have to convert stored procedures and the queries in the application too).
Post reply on HN