Export the data of a table as CSV
To export data from an SQLite table to a CSV file, you can use the following methods:
📌 Method 1: Using SQLite Command Line
- Open your SQLite database in the terminal:
- Set output mode to CSV:
- Set the output file name:
- Run the query to export:
- Exit SQLite:
✅ Now, my_table_data.csv
will contain your table data in CSV format.
📌 Method 2: Using SQL Query
If you're inside SQLite, run:
This exports data with column headers.
📌 Method 3: Using Python
If you prefer Python, use the csv
module:
✅ This will create my_table_data.csv
with column headers.
📌 Check Your Exported CSV
After exporting, verify the data using:
or
Let me know if you need further help! 🚀😊
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Import the CSV data into an SQLite table
To import CSV data into an SQLite table, use one of the following methods:
📌 Method 1: Using SQLite Command Line
- Open your SQLite database in the terminal:
- Enable CSV mode:
- Import the CSV file into the table:
- Verify the data:
✅ Your CSV data is now imported into my_table
.
📌 Method 2: Using Python
If you prefer Python, use the csv
module:
✅ This script reads my_data.csv
and inserts it into my_table
.
📌 Method 3: Using Pandas (If You Have Large Data)
If you're dealing with large CSV files, use pandas:
✅ Best for handling large datasets efficiently.
📌 Verify Import
Run this in SQLite to check your data:
Let me know if you need further help! 🚀😊
No comments:
Post a Comment