-
I have a sqlalchemy.Table object which has a create() method that would allow me to create the table in the database. It expects an 'engine' object. Is there a way I can use databases.Database() for this ? If i pass it directly i get:
Thank you. |
Beta Was this translation helpful? Give feedback.
Answered by
aminalaee
Sep 30, 2021
Replies: 1 comment 3 replies
-
So you want to create SQLAlchemy table? Update: import databases
import sqlalchemy
database = databases.Database("sqlite:///db.sqlite")
metadata = sqlalchemy.MetaData()
Table('my_table', metadata,
Column('id', Integer, primary_key=True),
Column('name', String(50))
)
engine = sqlalchemy.create_engine(str(database.url))
metadata.create_all(engine) Something along these lines should work. |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
bobbetter
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
So you want to create SQLAlchemy table?
There are some examples in
orm
repository which usedatabases
.Sorry I'm on phone, I will send an example later.
Update:
Something along these lines should work.