About 2,130,000 results
Open links in new tab
  1. Using SQLAlchemy to load a CSV file into a database

    May 9, 2024 · To import a relatively small CSV file into database using SQLAlchemy, you can use engine.execute(my_table.insert(), list_of_row_dicts), as described in detail in the "Executing Multiple Statements" section of the SQLAlchemy tutorial.

  2. Fastest way to import 1000s of big csv files to mysql database?

    Feb 18, 2022 · You should be able to import or export data using MySQL LOAD DATA and SELECT INTO FILE statements. Here’s an example of a successful data export query: mysql> SELECT * FROM your_table INTO OUTFILE "/tmp/out.txt"; Query OK, 6 rows affected (0.00 sec)

  3. How can I load a CSV into a database with SQLalchemy?

    May 16, 2019 · Given your model code above, here’s an example of how you might read corresponding records from CSV: import csv my_record_instances = [] with open('large-data.csv', 'r') as csv_file: csv_records = csv.reader(csv_file, delimiter = ',') for row in csv_records: my_instance = Asset.new_from_csv(','.join(row), delimiter = ',') my_record_instances ...

  4. Improve Data Loading Performance with SQLAlchemy and CSV Files

    Feb 18, 2025 · Connect to a database using SQLAlchemy. This is a basic example, and you can customize it further based on your specific needs, such as: Using more advanced SQLAlchemy features like declarative base and sessions. Adding error handling and logging. Handling different data types in your CSV file.

  5. Data Migration with Python: Streaming and Inserting Large

    Oct 14, 2024 · Using a combination of Pandas and SQLAlchemy, it’s possible to stream data in manageable chunks, reducing memory load and speeding up the process. In this article, we’ll explore how to...

  6. Importing Bulk CSV Data Into MySQL Using Python

    Dec 17, 2020 · The main objective of this tutorial is to find the best method to import bulk CSV data into MySQL. 2. Prerequisites. Python 3.8.3 : Anaconda download link MySQL : Download link. sqlalchemy : To install sqlalchemy use the command: pip install sqlalchemy 3. Prepare or Identify Your Data

  7. Loading CSV File into Database using SQLAlchemy in Python 3

    Mar 6, 2024 · Loading CSV files into a database using SQLAlchemy in Python 3 is a straightforward process. By using the pandas library, we can easily read the CSV file into a DataFrame and then use the SQLAlchemy engine to connect to the database.

  8. SQLAlchemy: How to Bulk Insert Data into a Table

    Jan 4, 2024 · Using SQLAlchemy for bulk inserts can improve the performance of your application by reducing transaction times and resource usage. Whether you’re dealing with basic bulk inserts or managing more complex scenarios with duplicate values or cascade operations, SQLAlchemy offers the tools you’ll need.

  9. Load Large Datasets into MySQL using Python - GitHub

    This repository contains a step-by-step Jupyter Notebook that demonstrates how to efficiently load large datasets from Excel or CSV files into a MySQL database using Python. 🔧 Tools Used: Python (Jupyter Notebook) pandas; SQLAlchemy; MySQL; Excel/CSV files

  10. Import CSV to database using sqlalchemy - Stack Overflow

    Apr 17, 2017 · I am using this example to upload a csv file into a sqlite database: this is my code: data = genfromtxt(file_name, delimiter=',')# skiprows=1, converters={0: lambda s: str(s)}) return data.tolist() #Tell SQLAlchemy what the table name is and if there's any table-specific arguments it should know about. __tablename__ = 'cdb1'

  11. Some results have been removed
Refresh