Ferreteria/v0.6/clade/Sys/Data/Engine/schema/Ops/MyMar/@fx/DoImport

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade‎ | Sys‎ | Data‎ | Engine‎ | schema‎ | Ops‎ | MyMar
Jump to navigation Jump to search

About

About

  • Action: import SQL data via command-line

Status

Code

as of 2025-12-02:

#
    public function DoImport(FileIface $ofData, bool $okToReplace) : ActionIface {
        $oScrn = self::Screen();

        $oAct = new ActionClass;

        #echo $this->ReflectThis()->Report();
        $sSchema = $this->QSchemaName()->GetIt();
        $oDBC = $this->DbConn();
          // 2025-06-05 TODO: get this from the Creds object now --
        $sCreds = $oDBC->CredsForCmd(); // db (inside) connection string

        #echo $ofData->Ident()->ReflectThis()->Report();
        $fsData = $ofData->Ident()->SpecFull();
        $ftFile = $oScrn->BlueIt($fsData);
        $ftSchema = $oScrn->GreenIt($sSchema);

        // Check to see if schema already exists
        if ($oDBC->OOper()->SchemaExists($sSchema)) {
            echo $oScrn->InfoIt('Found')." schema [$ftSchema]...".CRLF;

            #echo $this->ReflectThis()->Report();
            if ($okToReplace) {
                $sCmd = "echo 'CREATE OR REPLACE DATABASE $sSchema;'