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:

https://docs.sqlalchemy.org/en/14/core/tutorial.html#executing-multiple-statements

Hope that helps,

Simon

On Wed, Feb 23, 2022 at 8:42 PM janio mendonca junior
<[email protected]> wrote:
>
> 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). Same thing for the 
> insert, how to add rows to the multiple columns table without write column by 
> column?
>
> I have the data in a Data frame but I was not able to insert it using 
> df.to_sql from pandas. Do you guys have any similar example?
>
> Thank you all
>
> --
> SQLAlchemy -
> The Python SQL Toolkit and Object Relational Mapper
>
> http://www.sqlalchemy.org/
>
> To post example code, please provide an MCVE: Minimal, Complete, and 
> Verifiable Example. See http://stackoverflow.com/help/mcve for a full 
> description.
> ---
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sqlalchemy/CADF7wwb0_ncRuU_CadqFegE9583W-xWWD4x%3DGy8V%3DgW0jKtcyg%40mail.gmail.com.

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sqlalchemy/CAFHwexexvrpmr%3DEA4w%3DmncyiKyxj0yk%3Dcr9_%2Br%3Db3MCyOiHg%3DA%40mail.gmail.com.

Reply via email to