You get the impression that SQLAlchemy can only work with the database structure created by SQLAlchemy (possibly with MetaData.create_all()) - this is not true. SQLAlchemy can work perfectly with an existing database, you just need to define your models according to the database tables. One way to do this is to use reflection, as Ilya Everilya suggests:
class MyClass(Base):
__table__ = Table('mytable', Base.metadata,
autoload=True, autoload_with=some_engine)
(which, in my opinion, would be completely fine for one-time scripts, but can lead to incredibly frustrating errors in a "real" application, if there is potential that can change the structure of the database over time)
, , , . , . , 10 , users, id, name email:
class User(Base):
id = sa.Column(sa.Integer, primary_key=True)
name = sa.Column(sa.String)
email = sa.Column(sa.String)
( , , , DDL, String , email )
SQLAlchemy INSERT/UPDATE, . , , SELECT. , .