1 / 13

Converting Visual Fox DBF to SQL

Converting Visual Fox DBF to SQL. Tags: Visual Fox, DBF, SQL, MySQL, Converter Guide. What this is about:. Slides here will show you how to convert Visual Fox DBF database file into MySQL Knowledge required: PHP, MySQL

Download Presentation

Converting Visual Fox DBF to SQL

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Converting Visual Fox DBF to SQL Tags: Visual Fox, DBF, SQL, MySQL, Converter Guide

  2. What this is about: • Slides here will show you how to convert Visual Fox DBF database file into MySQL • Knowledge required: PHP, MySQL • There are commercial (and may be free) tools available, so my solution works fine for me and maybe you will be able to find right application • Script designed is universal (It automatically crease right table structure). • Software and products used are free and highly common

  3. Limitations • Please, extra check for your requirements. For example, I do not know about existence of calculated and what is more important pre-defined values in Visual Fox, so my script simply copy row by row without any clever mine inside • It’s better to create table structure yourself rather than rely on automatic creation (thought it is convenient when you do not care about space and you need to convert a lot of files) • Please, feel free to use presentation/code but without any warranties.

  4. My system • I run this script as a web page (Apache + MySQL + PHP) • Database that I used has Cyrillic encoding, so “iconv” converted to UTF-8 • My system is Windows 7 (this is important, as under Linux you will need another PHP libraries).

  5. Why SQL • Fast • SQL Language (creating complex select queries with parameters, functions, etc.) • Especially for my task: Possibility to perform fast joins as raw database that I investigate had structure unknown to me and I need to make filters/joins/multiple selects to test my assumptions.

  6. Why MySQL • One of possible solution is using SQL Server. The beautiful guide is available here -http://stackoverflow.com/questions/16819811/how-to-convert-visual-foxpro-database-into-sql-server-database • But I wanted free solution, so MySQL was my decision.

  7. dBase • Luckily the tool to read dbf files is build into PHP - http://www.php.net/manual/en/intro.dbase.php • But before usage you need to install it.

  8. Warning about DBF usage • There is no support for indexes or memo fields. There is no support for locking, too. Two concurrent web server processes modifying the same dBase file will very likely ruin your database. • We recommend that you do not use dBase files as your production database. Choose any real SQL server instead; » MySQL or » Postgres are common choices with PHP. dBase support is here to allow you to import and export data to and from your web database, because the file format is commonly understood by Windows spreadsheets and organizers.

  9. Installation • To run dbase function, you need to add line extension=php_dbase.dll to your php.ini and restart apache. • But it’s common (was my case and I saw similar problems at forums) that your system has not required php_dbase.dll In this case you can • Recompile your PHP and reinstall it. This is recommended (http://www.php.net/manual/en/dbase.installation.php) • Or download required library already compiled. (http://downloads.php.net/pierre/). It’s fast, but be careful with your PHP version and type (Thread safe vs. Non Thread Save)

  10. Script algorithm • Open DBF database and get table structure • Create dynamic query to create table • Connect to MySQL server • Run query to Create table • Open DBF rows • For each row: Do inserting into MySQL

  11. Script problems • When auto table creation is used, I add 20 bytes to the length of each column and declare them as varchar. If you need, you can write function that will distinguish INT, DATE,etc. with right column length. • I do not handle possible errors

  12. Script benefits • Auto table creation • Handling empty columns. I faced that number of columns in row can be less that needed, as some are regarded as empty or pre-set. • It’s free and easy to work with

  13. Finish • Code and this presentation is available • http://tigrantsat.me/randd/dbftomysql/ • Thank you.

More Related