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 4588228
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:53:33+00:00 2026-05-21T21:53:33+00:00

I have a large list of strings. I need to create a MySQL table

  • 0

I have a large list of strings. I need to create a MySQL table where each string in the list is a name of a column (all columns are integers).
(I’m on python with sqlalchemy).

I looked at examples and it looks like I need to explicitly write each column in schema.Table, which is not so practical for a large list.

Is it possible?

Thanks

  • 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-21T21:53:34+00:00Added an answer on May 21, 2026 at 9:53 pm

    You could use tuple unpacking here.

    >>> column_names = ['col1', 'col2', 'col3']
    >>> columns = (Column(name, Integer) for name in column_names)  
    >>> table = Table('table_name', metadata, *columns) # unpacks Column instances
    

    And here’s an extended example of how you could use this to programmatically create the column names from a list of strings:

    >>> column_names = ['col1', 'col2', 'col3']
    >>> columns = (Column(name, Integer) for name in column_names)
    >>> table = Table('data', metadata, Column('id', Integer, primary_key=True), *columns)
    >>> class Data(object):
    ...:     def __init__(self, *args):
    ...:         for name, arg in zip(column_names, args):
    ...:             setattr(self, name, arg)
    ...:             
    ...:
    >>> mapper(Data, table)
    <<< <Mapper at 0x1026e9910; Data>
    >>> data = Data(1, 2, 3)
    >>> [x for x in dir(data) if x.startswith('col')] # see if all of our columns are there
    <<< ['col1', 'col2', 'col3'] 
    >>> data.col3 # great!
    <<< 3           
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large list of values (100-200 character strings) and I need to
I have a large list (~ 110,000 strings), which I need to compare to
I have a large list of email addresses, and I need to determine which
I have a large table with list of scores like this, one score per
I have a large list of strings ( 1500 email addresses to be more
I have a set of strings and I need to find all all of
I have a large unsorted list of items. Some items are important and need
I have a list of strings, I need to be able to simply probe
I have a list of strings that are all early modern English words ending
I need to process a large list of short strings (mostly in Russian, but

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.