[Qgis-user] QGIS and MySQL

Julian Bogdani jbogdani at gmail.com
Wed Oct 17 09:24:22 PDT 2012


Hello Sebastiano,
I've used in the past mysql with spatial data in archaeological projects :)
There are several tool you can use to migrate shapefiles to mysql, first of all FWTools: http://fwtools.maptools.org/
I've successfully used this tutorial in the past: http://www.bostongis.com/PrinterFriendly.aspx?content_name=ogr_cheatsheet
There used to be another tool for windows, named SHP2MYSQL, but the link I had (http://www.kartografie.nl/rimapper/) is actually offline.
Check also this, if you are able to write some PHP: http://sourceforge.net/projects/shp2mysql-php/
Anyway ogr2ogr (from FWTools) is what you need to upload geodata to MySQL, it's a command line tool, but with a very simple syntax.

Once you have uploaded your data on the DB, you can use QGIS to read/edit/add/delete features.
i hope this helps


-----
Julian Bogdani
jbogdani at gmail.com
http://bradypus.net





On 17 Oct 2012, at 17:36 , Sebastiano Lora wrote:

> Hallo everybody,
> I have a some difficulties with QGIS and a MySQL database. I try to make it not so long, and work enviroment is WIN 7 64b; QGIS dev, MySQL 5.1.63
> 
> In my project (a GIS for an archaeological excavation) lot of data are stored in a MySQL database which was made before I joined it. Originally no geometry field was inserted in the MySQL tables and thereafter I have many features without stored geometry. My approach at the beginning was to create shapefiles (point and polygons mainly) of the features which I needed and to join them with the MySQL table that I imported into QGIS. Then now I have
> 
> shapefiles 
> MySQL tables 
> 
> Both have an ID which allow to join them together.
> 
> This worked just fine, but now I want to get rid of this double approach and use the MySQL database as a complete geodatabase (I know I should transfer it in postGRE but it is not a short-term possibility). The reasons are: a) I want to create a webgis of the project; b) since we are now more persons who are working with  GIS I would like that more than one user could work on the same shapefile at the same time; c) it is more "elegant". 
> 
> Now my question is how I merge the spatial information from the shapefiles into the MySQL tables?
> 
> for the point shapefiles it was not a big problem since I had the lat long coordinates stored in the db, I just create a query which writes them in the POINT field.
> 
> for the polygons is not so easy.
> 
> I tried to install the QGIS plugin "export to MySQL" with the idea:
> - export the shapefile into MySQL
> - update the table with the geometry field
> 
> but the plug-in does not work since a module is missing (MySQLdb). There is already a lot of documentation on it which I read. An installer for is also available BUT it is not working with my OSGEO installation. It seems that it is installing the module in a second installation of php that I have and not in for the php installed by the OSGEO, which is the one that QGIS is calling. Compiling it by myself is out of my skills.
> (of course I could export my shapefile in .csv, import it in MySQL and than run the query BUT I was looking for something simpler and that I could use often)
> 
> Finally:
> somebody who had success in installing the export to Mysql plug-in in one OSGEO installation could tell me what I should do?
> Anybody has some suggestion how to solve my problem?
> 
> Thanks in advance
> Sebastiano
> 
> 
> 
> 
> 
> -- 
> Sebastiano Lora Dr phil
> Deutsches Archäologische Institut Orient-Abteilung
> Podbielskiallee 69-71
> 14195 Berlin, Germany
> Tel. +49-30-187711-265
> Fax +49-30-187711-189
> cell 00491627638459
> sebastiano.lora at gmail.com
> skype: sebastiano.lora
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user




More information about the Qgis-user mailing list