Contoh 1
export database :
EXECSCRIPT("run mysqldump -u username -pPassword nama_db > C:/FOXPRO/backup/File_hasil_Export.sql")
contoh :
EXECSCRIPT("run mysqldump -u root -p123456 penjualan > C:/FOXPRO/backup/File_hasil_Export.sql")
import database :
EXECSCRIPT("run mysql -u username -pPassword nama_db < C:/FOXPRO/backup/File_hasil_Export.sql")
contoh :
EXECSCRIPT("run mysql -u root -p123456 penjualan < C:/FOXPRO/backup/File_hasil_Export.sql")
Seting mysql
Contoh 2
Export tabel
ftujuan = CHRTRAN(ALLTRIM(thisform.Text1.Value),'\','/')
random_nomor = ALLTRIM(STR(int(Rand () * 100 + 1)))
TIME_IMPORT = DTOS(DATE())+'_'+CHRTRAN(ALLTRIM(TIME()),':','-')+random_nomor
*-----------------------------------------------mulai import
filetarget = ftujuan+'tabel_akademi_negeri'+'_'+TIME_IMPORT+".csv"
TEXT TO tabel_akademi_negeri TEXTMERGE NOSHOW
SELECT * FROM tabel_akademi_negeri INTO OUTFILE ?filetarget;
ENDTEXT
oke = SQLEXEC(ConnHandle,tabel_akademi_negeri)
*----------------------------------------------------------------------------------------------------------
filetarget = ftujuan+'tabel_akademi_swasta'+'_'+TIME_IMPORT+".csv"
TEXT TO tabel_akademi_swasta TEXTMERGE NOSHOW
SELECT * FROM tabel_akademi_swasta INTO OUTFILE ?filetarget;
ENDTEXT
oke = SQLEXEC(ConnHandle,tabel_akademi_swasta)
*----------------------------------------------------------------------------------------------------------
IF oke != 0
MESSAGEBOX("Database berhasil diexport, silahkan periksa di folder : "+ftujuan,64,"Informasi !")
Thisform.Refresh
thisform.Release()
ELSE
MESSAGEBOX("Database gagal diimport.",64,"Informasi !")
Thisform.Refresh
endif
Import tabel
LOCAL t01,t02
SET POINT TO '.'
folder = CHRTRAN(ALLTRIM(thisform.text1.Value),'\','/')
file_csv = ALLTRIM(thisform.text2.Value)
fasal = folder+'tabel_akademi_negeri_'+file_csv+'.csv'
MESSAGEBOX(fasal,64,"Informasi !")
xnamadb = 'tabel_akademi_negeri'
filetarget = "'"+fasal+"'"
TEXT TO csv2mysql TEXTMERGE NOSHOW
LOAD DATA LOCAL INFILE <<filetarget>>
IGNORE INTO TABLE <<xnamadb>>
ENDTEXT
SQLEXEC(ConnHandle,csv2mysql)
fasal = folder+'tabel_akademi_swasta_'+file_csv+'.csv'
MESSAGEBOX(fasal,64,"Informasi !")
xnamadb = 'tabel_akademi_swasta'
filetarget = "'"+fasal+"'"
TEXT TO csv2mysql TEXTMERGE NOSHOW
LOAD DATA LOCAL INFILE <<filetarget>>
IGNORE INTO TABLE <<xnamadb>>
ENDTEXT
SQLEXEC(ConnHandle,csv2mysql)
Posted in: Foxpro
0 komentar:
Posting Komentar