Skip to content

Update sqlserver2pgsql.pl#26

Closed
hgeorgilas wants to merge 1 commit into
dalibo:masterfrom
hgeorgilas:master
Closed

Update sqlserver2pgsql.pl#26
hgeorgilas wants to merge 1 commit into
dalibo:masterfrom
hgeorgilas:master

Conversation

@hgeorgilas

Copy link
Copy Markdown

Just added xml and geography data types
xml > xml
geography > point

Really nice script btw, it saved me a lot of time, moving from SQL server to Postgresql is a pain in the ass 👎 . Your script helped me 👍

@marco44

marco44 commented Aug 4, 2015

Copy link
Copy Markdown
Contributor

I'm a bit worried about the geography data type…

This is much closer to the PostGIS geography type. This conversion wont work, I think, except in the most simple of cases (only points stored). Can you confirm this (I'm a PostgreSQL guy :) )

@hgeorgilas

Copy link
Copy Markdown
Author

You are right, geography data type is much closer to PostGIS, but PostGIS is an extension of postgresql (at least I think so), I have mostly used MySQL & MSSQL , I'm a newbie in postgresql but when I stored coordinates in MSSQL I used the SqlGeography.Point Method , which is very similar to the point method of postgresql.

More about that here: SqlGeography.Point Method (Double, Double, Int32)

I know this is not a necessary pull request, I just encountered some errors when I was trying to convert xml and geography fields so I just used what was closer from one DB to another :)

@marco44

marco44 commented Aug 4, 2015

Copy link
Copy Markdown
Contributor

Yeah, sure, PostGIS is an extension. My point is that in 95% of cases, people migrating from SQL Server to PostgreSQL that have a geography type in SQL Server will need a geography type in PostgreSQL, and the full-fledged PostGIS. PostGIS itself is very easy to install, as long as you have packages (which you have for Redhat derivatives, Debian derivatives and Windows at least).

So I'm thinking of a "bigger" patch, that will, as soon as a geography or geometry type is detected:

  • print a warning
  • maybe advise to use GeoKettle (or call the appropriate WKT functions in SQL Server to extract, I'll have to ask a friend of mine who is more proficient in GIS than I am)
  • create the PostGIS extension
  • convert geography to geography, and geometry to geometry

I will work on this when I have a little bit of time.

@hgeorgilas

Copy link
Copy Markdown
Author

Ok, it helped me a great deal today and I hope you will continue working on it because it's a great little script, all other software that is capable of migrating MSSQL to Postgresql is proprietary. When I thought all hope is lost and I had to edit the migrations by hand I stumbled upon your script 👍

@marco44

marco44 commented Aug 5, 2015

Copy link
Copy Markdown
Contributor

Could you send me your SQL Server script at cousinmarc@gmail.com ? I'd like to check the patch I'm working on. It wont be public, I'll only use it for my regression testing

Regards

@hgeorgilas

Copy link
Copy Markdown
Author

I'm afraid I can't send you the whole schema (I'm working for a company) but If you are ok with some partial data I think it won't be a problem

@marco44

marco44 commented Aug 5, 2015

Copy link
Copy Markdown
Contributor

On Wednesday 05 August 2015 07:05:47 Harry wrote:

I'm afraid I can't send you the whole schema (I'm working for a company) but
If you are ok with some partial data I can send you

Ok.

@marco44

marco44 commented Aug 10, 2015

Copy link
Copy Markdown
Contributor

Could you send me the extract from the schema ?

Regards.

@marco44

marco44 commented Aug 14, 2015

Copy link
Copy Markdown
Contributor

I just need an example table… Can you take one of yours and anonymize its fields name ?

Thanks

@hgeorgilas

Copy link
Copy Markdown
Author

Hello friend, sorry I was on vacation and had no internet access.
The schema has about 30 tables, do you need the relations to be present or should I just anonimize the main tables and send you the script.
Thanks

@marco44

marco44 commented Aug 23, 2015

Copy link
Copy Markdown
Contributor

Hi,

just give me one table with geography in it, that will be sufficient.

Thanks a lot.

@hgeorgilas

Copy link
Copy Markdown
Author

Here is a pastebin with the table script as it was produced from MSSQL server 2012 that contains the geography field, i have anonymized the fields.
I would be interested in creating a gui for your script (in java maybe) or port your perl script in java entirely when I have time.
Regards

@marco44

marco44 commented Aug 23, 2015

Copy link
Copy Markdown
Contributor

The GUI may be an idea. There are very few parameters though, so I don't know if it is worth the work.

Rewritting this program in Java would seem a bit weird to me. And, as it is all about parsing the dump, I think it will be much harder, and very boring to write in Java.

@marco44

marco44 commented Aug 23, 2015

Copy link
Copy Markdown
Contributor

I added support for geography. It installs the postgis extension and warns the user that Postgis must be installed. Commit d1ef8b7

@hgeorgilas

Copy link
Copy Markdown
Author

nice work 👍
I will try to port this into java when I have the time, it a shame that someone must pay to get a decent migration. If I do it I will give you attribution, since i will just try to port to script and create a basic UI to be more user friendly for the average user or someone who has little experience with UNIX systems.
Have a good day

@marco44

marco44 commented Aug 24, 2015

Copy link
Copy Markdown
Contributor

As you want. Someone with no Unix experience should probably not switch to PostgreSQL though, except for very small databases, as PostgreSQL's performance is much lower with Windows.

@marco44 marco44 closed this Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants