[Gambas-user] import mysql dump EXEC or SHELL?

wig wig at ...1809...
Tue Dec 16 12:20:06 CET 2008


> wig wrote:
>> Although I can create table by table from within Gambas with
>> hCon.Databases.Add(sDbName), I wondered if there is a way to "import" a
>> mysql dump file, so that I can create the tables with data (in one
>> command).
>>
>> Untill now I allways used phpMyAdmin dump/export and import for creating
>> the database structure and initial data, but I want to integrate it in
>> my
>> Gambas application.
>>
>>

> You could use the EXEC command to run the appropriate mysqlsomething
> utility (don't recall which)
>
> Regards
> Werner
>

I couldn't get it to work with EXEC;

  sImport = "< " & Application.Path & "/mytables.sql"
' ...
  EXEC ["mysql", sUser, sPassword, sHost, sDatabase, sImport]

Everything works fine except the last part that gives the file to read from.

I get the general help of mysql, not a specific error like when I change
the password to a wrong one.

Maybe there is a difference between the normal parameters and the way to
give the file to import from?


I could get it to work with SHELL though:

  sImport = "< " & Application.Path & "/mytables.sql"
'...
  sCommand = "mysql " & sUser & " " & sPassword & " " & sHost & " " &
sDatabase & " " & sImport
  DEBUG sCommand
  SHELL sCommand WAIT

Ok!  Don't know which is the "preferred" way but this works.







More information about the User mailing list