gw2sqlA SQL to GeneWeb converterby Yann Corno - last update: 2006-05-01 |
Contents
sql2gw performs the opposite as its gw2sql counterpart: converting a SQL database into a GW source file that can be imported into GeneWeb using the gwc
tool that is included with GeneWeb.
See the GeneWeb documentation for details about this file format.
It is a PERL script, so it can be used on any platform. Before using this tool, it is recommanded to read and play with gw2sql to learn some basic concepts.
perl sql2gw.pl [-o outfile.gw] [-v|--verbose] [--utf8] [-q lastname]
Parameters in [brakets] are optional.
-o outfile.gw name of the output GeneWeb file. If omitted, standard output is used. -v, --verbose display progress. Only if -o option is used. --utf8 insert "encoding: utf-8" at the beginning of the GW file. Use it if your SQL database contains UTF-8 data. -q lastname output only families where one parent have this last name
the following example makes a complete transfer of a SQL database into a fresh GeneWeb one named "yourGeneWebDB":
perl sql2gw.pl -o YourGeneWebBase.gw gwc YourGeneWebBase.gw -o yourGeneWebDB
sql2gw converts a genealogical SQL database into a GW file (GeneWeb source file).
It is designed to work with the SQL table structures created by its counterpart, gw2sql. See the gw2sql page to learn about the role of the various tables.
Adapting sql2gw.pl to your own needs and database
There are two things to do, which are performed by editing the sql2gw.pl script:
perl gw2sql.pl --nodata | mysql yourDatabase
INSERT INTO gw_person (lastname, firstname) SELECT last_name, first_name FROM persons;
Once all your SQL commands are finished and tested, you should put them in a text file to be able to run them automatically next time.
Download sql2gw.pl (24 KB)
See header of script file.
Special thanks to my friend Erich from Germany, who kindly tested my script, uncovering many bugs. There is no good programmer without a good tester, and Erich is a great one!
This program is made available under the GeneWeb GPL Licence. GeneWeb is a software developed by Daniel de Rauglaudre, and is © Copyright INRIA. You may change and distribute this work as long as you comply with the GeneWeb GPL Licence.
IMPORTANT NOTICE: THIS WORK IS PROVIDED FOR EXPERIMENTAL PURPOSES ONLY. THERE ARE ABSOLUTELY NO WARRANTY WHATSOEVER THAT COMES WITH THIS SOURCE CODE AND THE INFORMATION DESCRIBED IN THIS PAGE. YOU MAY LOOSE YOUR DATA AND/OR HAVE COMPUTER HARDWARE OR SOFTWARE DAMAGES, OR SECURITY BREACHES. YOU ARE USING ALL THIS AT YOUR OWN RISKS. YOU HAVE BEEN WARNED !
You feed back or source code contributions are welcome! Contact me at . Have fun.
Yann Corno
Back to Yann's GeneWeb Tools