mysqlcli how to load external sql file 1

mysqlcli how to load external sql file

 mysql --user="username" --database="databasename" --password="yourpassword" < "filepath"

Here is what the above code is Doing:
1. It's connecting to the database using the mysql.connector.connect() method.
2. It's creating a cursor object using the cursor() method.
3. It's executing the SQL query using the execute() method. Note that the execute() method also supports bulk operations.
4. It's fetching all the rows from the result set and printing them to the console.
5. It's closing the database connection and the cursor object.

Similar Posts