Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6876755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:31:02+00:00 2026-05-27T04:31:02+00:00

I want to insert some data into a table and I want the multiple

  • 0

I want to insert some data into a table and I want the multiple insertion to be as fast as possible. I use sqlalchemy library for Python. I want to know if my insertion is optimal, or there is a better way to do that.Here is my code:

 from sqlalchemy import *
    from sqlalchemy import schema

    metadata = schema.MetaData()

    engine = create_engine('sqlite:///:memory:', echo=True)

    users = Table('users', metadata,
        Column('id', Integer, primary_key=True),
        Column('firstname', String(40)),
        Column('lastname', Integer),
        )

    metadata.create_all(engine) 
    ins = users.insert()
    conn = engine.connect()

    conn.execute(users.insert(), [ 
      {'id': 1, 'firstname' : 'Name1', 'lastname' : 'Lname1'},
      {'id': 2, 'firstname' : 'Name2', 'lastname' : 'Lname2'},
      {'id': 3, 'firstname' : 'Name3', 'lastname' : 'Lname3'}
    ])

    metadata.bind = engine
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:31:02+00:00Added an answer on May 27, 2026 at 4:31 am

    If you see the log then you can check that

    2011-11-22 10:15:37,188 INFO sqlalchemy.engine.base.Engine SELECT DATABASE()
    2011-11-22 10:15:37,188 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,191 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'character_set%%'
    2011-11-22 10:15:37,191 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,193 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'lower_case_table_names'
    2011-11-22 10:15:37,193 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,194 INFO sqlalchemy.engine.base.Engine SHOW COLLATION
    2011-11-22 10:15:37,194 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,200 INFO sqlalchemy.engine.base.Engine SHOW VARIABLES LIKE 'sql_mode'
    2011-11-22 10:15:37,201 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,203 INFO sqlalchemy.engine.base.Engine DESCRIBE `users`
    2011-11-22 10:15:37,203 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,204 INFO sqlalchemy.engine.base.Engine ROLLBACK
    2011-11-22 10:15:37,206 INFO sqlalchemy.engine.base.Engine 
    CREATE TABLE users (
        id INTEGER NOT NULL AUTO_INCREMENT, 
        firstname VARCHAR(40), 
        lastname INTEGER, 
        PRIMARY KEY (id)
    )
    
    
    2011-11-22 10:15:37,206 INFO sqlalchemy.engine.base.Engine ()
    2011-11-22 10:15:37,331 INFO sqlalchemy.engine.base.Engine COMMIT
    2011-11-22 10:15:37,333 INFO sqlalchemy.engine.base.Engine INSERT INTO users (id, firstname, lastname) VALUES (%s, %s, %s)
    2011-11-22 10:15:37,333 INFO sqlalchemy.engine.base.Engine ((1, 'Name1', 'Lname1'), (2, 'Name2', 'Lname2'), (3, 'Name3', 'Lname3'))
    

    Only one insert with all values so I think this is the best way to insert bulk/batch data.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert some data into a table (id PK autoincrement, val) with
So, I want to insert some data into a MySQL table where the table
I want to insert some data into a table associated with dates for the
i want to insert some data into a data table, for a wordpress plugin.
I want to insert data into sql table in silverlight application. I know how
I want to use javascript to insert some elements into the current page. Such
I need to create an SQL query to insert some data into a table
I want to insert some simple data the query is: INSERT INTO categories_lang (category_id,language_id,name,description,alias)
I am trying to insert some data into one table and after that is
After creating a table (by migration), I want to insert some entries directly. How

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.