0% found this document useful (0 votes)
6 views

ExcelTOmysql

The document provides instructions for saving an Excel file as a CSV and importing it into a MySQL database named 'boatdb'. It details the steps to create a database, define a table schema for boats, and load data from the CSV file into the MySQL table. Additionally, it mentions the option to connect the MySQL database to Chartio for data visualization.

Uploaded by

uu061435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

ExcelTOmysql

The document provides instructions for saving an Excel file as a CSV and importing it into a MySQL database named 'boatdb'. It details the steps to create a database, define a table schema for boats, and load data from the CSV file into the MySQL table. Additionally, it mentions the option to connect the MySQL database to Chartio for data visualization.

Uploaded by

uu061435
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Open your Excel file and click Save As. Choose to save it as a .

CSV (Comma
Separated) file. If you are running Excel on a Mac, you will need to save the file
as a Windows Comma Separated (.csv) or CSV (Windows) to maintain the correct
formatting.

Log into your MySQL shell and create a database. For this example the database will
be named boatdb.
Note that the --local-infile option is needed by some versions of
MySQL for the data loading we’ll do in the following steps.
--> $ mysql -u root -p --local-infile
--> mysql> create database boatdb;
--> mysql> use boatdb;
Next we’ll define the schema for our boat table using the CREATE TABLE command.
For more details, see the MySQL documentation.
CREATE TABLE boats (
d INT NOT NULL PRIMARY KEY,
name VARCHAR(40),
type VARCHAR(10),
owner_id INT NOT NULL,
date_made DATE,
rental_price FLOAT
);
Run show tables to verify that your table was created.
mysql> show tables;
+------------------+
| Tables_in_boatdb |
+------------------+
| boats |
+------------------+
Now that there is a database and a table setup, the data can be imported with the
LOAD DATA command.
LOAD DATA LOCAL INFILE "/path/to/boats.csv" INTO TABLE boatdb.boats
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(id, name, type, owner_id, @datevar, rental_price)
set date_made = STR_TO_DATE(@datevar,'%m/%d/%Y');
If you are a Chartio user, you can now connect the MySQL database to Chartio and
chart away.

You might also like