I have two legacy MySQL databases for which I would like to define an ORM class-model in Peweby (Python). Specifically, some information between the front-end data, other back-end data and database tables in a database is linked from one database to another with the foreign key . I could not find a direct way to add a foreign key between the tables. Apart from this, I have tried to create a paywell model with the help of supply, which was successfully working on front-end database but not on back-end (possibly because back-end only refers to front-end -versa). However, I would like to ask whether such a model is possible with two databases. Support foreign keys in pev multiple databases. example code (not the actual code, which is inspired by example in the quick start):
Import peewee frontend = peewee.MySQLDatabase ('frontend', host = Host, user = user, passwd = passwd) backend = pevy My SQL Database ('Backend', Host = Host, User = User, PassWOOD = Password) Class User (Peiv.Model): Name = Pevi.Kirfild () Square Meta: Database = Frontend Class Tweet (Peiv.Model): User = Paivis Finnishiskild (user, related_name = 'Tweets') content = pevy. Going through the textfield () class meta: database = backend
No comments:
Post a Comment