Run a MySQL command with `$db_settings`.

@param string $sql_cmd Command to run.
@param array $assoc_args Optional. Associative array of options. Default empty.
@param bool $add_database Optional. Whether to add dbname to the $sql_cmd. Default false.
556094
private static function run_sql( $sql_cmd, $assoc_args = array(), $add_database = false ) {
		$default_assoc_args = array(
			'host' => self::$db_settings['dbhost'],
			'user' => self::$db_settings['dbuser'],
			'pass' => self::$db_settings['dbpass'],
		);
		if ( $add_database ) {
			$sql_cmd .= ' ' . escapeshellarg( self::$db_settings['dbname'] );
		}
		$start_time = microtime( true );
		Utils\run_mysql_command( $sql_cmd, array_merge( $assoc_args, $default_assoc_args ) );
		if ( self::$log_run_times ) {
			self::log_proc_method_run_time( 'run_sql ' . $sql_cmd, $start_time );
		}
	}
1048503
function _connect($argHostname, $argUsername, $argPassword, $argDatabasename)
	{
		if (empty($argHostname) && $argDatabasename) {
			$argHostname = $argDatabasename;
		}
		$this->_connectionID = new SQLite3($argHostname);
		$this->_createFunctions();

		return true;
	}
943212
public function cmdSqlDatabase()
    {
        $sql = $this->getParam(0);

        if (empty($sql)) {
            $this->errorAndExit($this->text('Invalid command'));
        }

        $result = $this->db->query($sql);

        if ($this->getParam('fetch')) {
            $result = $result->fetchAll(\PDO::FETCH_ASSOC);
            $this->outputFormat($result);
            $this->outputFormatTableDatabase($result);
        }

        $this->output();
    }
1345413
def db_exec(self, sql: str, *args) -> int:
        """"""
        self.ensure_db_open()
        cursor = self.db.cursor()
        return self.db_exec_with_cursor(cursor, sql, *args)
1176295
public function setup($args)
    {
        if(count($args) < 2) {
            Index::error('Not enough arguments.', 'Usage: eve database <schema>');
        }

        $this->name = $args[1];

        $file = $this->cwd.'/schema/'.$this->name.'.php';

        if(!file_exists($file)) {
            Index::error('Cannot find schema/' . $this->name . '.php');
        }

        $this->schema = include($this->cwd . '/schema/' . $this->name . '.php');

        if(!is_array($this->schema)) {
            Index::error('Schema is invalid.');
        }

        $file = $this->cwd.'/settings/databases.php';

        if(!file_exists($file)) {
            Index::error('Cannot find settings/databases.php');
        }

        $databases = include($this->cwd . '/settings/databases.php');

        if(!is_array($databases)) {
            Index::error('Database is invalid.');
        }

        foreach($databases as $config) {
            if($config['type'] === 'mysql' && $config['default']) {
                $database = $config;
            }
        }

        if(!$database) {
            Index::error('No valid database found.', false);
            Index::error('Needs to be of mysql type and set to a default');
        }

        $this->database = $this(
            'mysql',
            $database['host'],
            $database['name'],
            $database['user'],
            $database['pass']);

        return $this;
    }
171811
public static void update(String sql, Object... arg) {
        Connection connection = JDBCUtils.getConnection();
        PreparedStatement ps = null;
        try {
            ps = connection.prepareStatement(sql);
            for (int i = 0; i < arg.length; i++) {
                ps.setObject(i + 1, arg[i]);
            }
            ps.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        JDBCUtils.release(ps, connection);
    }
223457
public static void command(final ODatabaseObject db, final String command, final Object... args) {
        db.command(new OCommandSQL(String.format(command, args))).execute();
    }
498002
public function create( $args, $assoc_args ) {

		$menu_id = wp_create_nav_menu( $args[0] );

		if ( is_wp_error( $menu_id ) ) {

			WP_CLI::error( $menu_id->get_error_message() );

		} else {

			if ( Utils\get_flag_value( $assoc_args, 'porcelain' ) ) {
				WP_CLI::line( $menu_id );
			} else {
				WP_CLI::success( "Created menu {$menu_id}." );
			}
		}
	}
1287492
public function setSql($sql, array $params = [])
    {
        $this->sql = (string) $sql;

        $this->setSqlParameters($params);
    }
1116044
public function select($sql, $args = array())
    {
        return $this->build($this->db->select($sql, $args));
    }
1288691
def db_command(parser_args):
    
    from synergy.db.manager import db_manager

    if parser_args.reset:
        db_manager.reset_db()
        # initialize DB with the context.process_context entries
        parser_args.update = True

    if parser_args.update:
        db_manager.update_db()
366941
public function run_update($sql, array $params=null, array $driverOptions=array()) {
		return($this->run_query($sql, $params, $driverOptions));
	}
880206
def sql(
    state, host, sql,
    database=None,
    # Details for speaking to MySQL via `mysql` CLI
    mysql_user=None, mysql_password=None,
    mysql_host=None, mysql_port=None,
):
    '''
    
    '''

    yield make_execute_mysql_command(
        sql,
        database=database,
        user=mysql_user,
        password=mysql_password,
        host=mysql_host,
        port=mysql_port,
    )
987691
protected function _execute( $sql, $name = 'db' )
	{
		$this->_getConnection( $name )->create( $sql )->execute()->finish();
	}
848231
public function run_insert($sql, array $params=null, $seqName=null, array $driverOptions=array()) {
		
		#$this->sth = $this->dbh->prepare($sql, $driverOptions);
		#$this->sth->execute($params);
		$numRows = $this->run_query($sql, $params, $driverOptions);
		
		if($numRows > 0 && is_object($this->dbh)) {
			$retval = $this->dbh->lastInsertId($seqName);
		}
		else {
			throw new \Exception(__METHOD__ .": insert failed");
		}
		
		#$retval = $this->dbh->lastInsertId($seqName);
		return($retval);
	}
237045
public function cmd($command, $extra = null, $db = null)
    {
        return $this->connection->cmd($this, $command, $extra, $db);
    }
903473
public void doSQL(final String sql) throws SQLException {

		LOG.info("Connecting to: " + this.dbString + " with " + this.usr
				+ " and " + this.pwd);
		LOG.info("Running: " + sql);
		Connection connection = null;
		Statement st = null;

		try {
			connection = DriverManager.getConnection(this.dbString, this.usr,
					this.pwd);

			st = connection.createStatement();
			st.executeUpdate(sql);

		} finally {

			if (st != null) {
				st.close();
			}
			if (connection != null) {
				connection.close();
			}
		}

	}