I think we keep it in RAM in the first method, so it may be a problem if 
the program is restarted. and I guess I don't understand what you mean by 
Base class.
17 Mart 2021 Çarşamba tarihinde saat 14:27:31 UTC+3 itibarıyla Simon King 
şunları yazdı:

> There are lots of ways of doing this. One option is to provide a
> dictionary when creating your declarative_base:
>
> classes = {}
> Base = declarative_base(class_registry=classes)
>
> Now you can look up classes by name in that classes dictionary:
>
> def get_table_by_name(name):
> return classes[name]
>
> Another option could be to iterate over Base.__subclasses__:
>
> def get_table_by_name(name):
> for cls in Base.__subclasses__():
> if cls.__name__ == name:
> return cls
>
> Hope that helps,
>
> Simon
>
> On Tue, Mar 16, 2021 at 7:14 PM FURKAN bilgin <[email protected]> wrote:
> >
> > table_name = "table_name"
> >
> > #get table as table
> >
> > new = table(**tablo)
> > db.session.add(table)
> > db.session.commit()
> >
> > --
> > 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/c3c7c369-7d7f-41b0-b6f3-273b6c76314dn%40googlegroups.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/1f98d725-f15f-4fde-9fe2-4205f71eb1d8n%40googlegroups.com.

Reply via email to