Re: [sqlalchemy] What is the best way to declare a table with 260 columns and add rows on that table

2022-02-25 Thread janio mendonca junior
Hi Simon, Thank you for your explanation. I managed to create the table by using df.to_sql. My mistake was because I was using a serie to sql instead of a dataframe. On Fri, Feb 25, 2022 at 5:33 AM Simon King wrote: > I don't know enough about Pandas to explain your error, but I did >

Re: [sqlalchemy] What is the best way to declare a table with 260 columns and add rows on that table

2022-02-25 Thread Simon King
I don't know enough about Pandas to explain your error, but I did notice that the SQL that is failing is trying to insert into a table called "mlstreb", but elsewhere in your code you refer to "mls_treb". Could that be part of the problem? To define a table from your CSV file, you could do

Re: [sqlalchemy] What is the best way to declare a table with 260 columns and add rows on that table

2022-02-24 Thread Simon King
Before we do that, you said that you tried pandas dataframe.to_sql but it didn't work - can you explain what you mean? Did it raise an error, or produce the wrong result, or something else? Simon On Wed, Feb 23, 2022 at 9:13 PM janio mendonca junior wrote: > > Hi Simon, > > Thank you for your

Re: [sqlalchemy] What is the best way to declare a table with 260 columns and add rows on that table

2022-02-23 Thread janio mendonca junior
Hi Simon, Thank you for your help. I am brand new working with SQLalchemy, really appreciate if you explain how to generate the metadata with the list of column names from the .CSV to create the tables? On Wed, Feb 23, 2022, 3:52 PM Simon King wrote: > Build a list of Column objects from the

Re: [sqlalchemy] What is the best way to declare a table with 260 columns and add rows on that table

2022-02-23 Thread Simon King
Build a list of Column objects from the columns in the CSV file, and use that list to create a Table: https://docs.sqlalchemy.org/en/14/core/metadata.html Once you've created the Table, you can insert data into it using the table.insert() method:

[sqlalchemy] What is the best way to declare a table with 260 columns and add rows on that table

2022-02-23 Thread janio mendonca junior
Hi all, I have a inquiry from my job to create 2 tables related one-to-one and insert some rows on the table. I have a .CSV with the data dictionary from the table and I am wondering to know how to declare the tables columns automatically without write one by one column (there are 260 columns).