Category: Türkçe
Here, you can find a Python script I've written which lets you convert your csv files to MySQL-understandable SQL statements. The main feature is that this script detects the field types (INT, VARCHAR, DATE for now) according to the values belonging to each field and it generates both CREATE TABLE and INSERT INTO statements.
This script is useful when you cant import your OpenOffice Base database to MySQL. All you have to do is:
- Right click on your Base tables and click copy.
- Paste into a spreadsheet.
- Save it as a CSV file.
- Do the first 3 step for all tables
- Put all the CSV files under /home/user/tables directory.
- Run: python csvtomysql.py > output.sql
Script is licenced under GPLv2.
Sample input:
id; name
1; emre
2; john
- Base içerisinde istediğiniz tabloya sağ tıklayın ve Kopyalayı seçin.
- Boş bir Hesap Tablosu açın ve içine yapıştırın.
- CSV biçeminde Farklı Kaydedin.
- İstediğiniz tüm tablolar için yukarıdaki 3 adımı uygulayın.
- Tüm CSV dosyalarınızı /home/kullaniciniz/tables dizini altında toplayın.
- Betiğin bulunduğu konumda şu komudu çalıştırın: python csvtomysql.py > cikti.sql
Bu betik GPLv2 ile lisanslanmış olup okuldaki veritabanı dersinde verilen projeyi OpenOffice Basede yapıp bunu ne Accesse, ne de MySQLin anlayacağı bir SQL biçemine çevirmekte aciz kalan bir öğrenci tarafından yazılmıştır. Umarım birilerine faydası dokunur...
Örnek CSV dosyası:
id; name
1; emre
2; john
NOT: Sonradan öğrendim, http://www.csv2mysql.com/ diye bir site mevcutmuş, ancak ayraç olarak ; kullanıldığında sapıttığını belirtmek lazım.