Я пытаюсь создать таблицу самооценки в MySQL, используя SQLalchemy. Я получаю ошибку
typeerror: Дополнительные аргументы должны быть названы _, Got 'foreignKey' < /p>
Мой код < /p>
from sqlalchemy import (
create_engine,
Column,
Integer,
String,
DateTime,
func,
Text,
DECIMAL,
ForeignKey,
)
# from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, declarative_base, mapped_column, relationship
Base = declarative_base()
class Account(Base):
__tablename__ = "account"
id = mapped_column(Integer, primary_key=True)
name = mapped_column(String(50))
notes = mapped_column(Text())
opening_balance = DECIMAL()
current_balance = DECIMAL()
parent_id = mapped_column(Integer, ForeignKey="account.id") #error here
children = relationship("Account")
created_at = mapped_column(DateTime, default=func.now())
updated_at = mapped_column(DateTime, default=func.now(), onupdate=func.now())```
the error occurs at the line parent_id = ...
everywhere I look suggests that the code is correct (and I've looked in a lot of places). Co-Pilot told me to put () around "account.id" but PyCharm told me they were redundant. Either way got the error. Tried changing mapped_column to Column, same error.
Havent got a clue what to do!
Подробнее здесь: https://stackoverflow.com/questions/794 ... -for-mysql
Как мне создать таблицу соединений в SQLALCHEMY для MySQL ⇐ MySql
Форум по Mysql
-
Anonymous
1739527806
Anonymous
Я пытаюсь создать таблицу самооценки в MySQL, используя SQLalchemy. Я получаю ошибку
typeerror: Дополнительные аргументы должны быть названы _, Got 'foreignKey' < /p>
Мой код < /p>
from sqlalchemy import (
create_engine,
Column,
Integer,
String,
DateTime,
func,
Text,
DECIMAL,
ForeignKey,
)
# from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, declarative_base, mapped_column, relationship
Base = declarative_base()
class Account(Base):
__tablename__ = "account"
id = mapped_column(Integer, primary_key=True)
name = mapped_column(String(50))
notes = mapped_column(Text())
opening_balance = DECIMAL()
current_balance = DECIMAL()
parent_id = mapped_column(Integer, ForeignKey="account.id") #error here
children = relationship("Account")
created_at = mapped_column(DateTime, default=func.now())
updated_at = mapped_column(DateTime, default=func.now(), onupdate=func.now())```
the error occurs at the line parent_id = ...
everywhere I look suggests that the code is correct (and I've looked in a lot of places). Co-Pilot told me to put () around "account.id" but PyCharm told me they were redundant. Either way got the error. Tried changing mapped_column to Column, same error.
Havent got a clue what to do!
Подробнее здесь: [url]https://stackoverflow.com/questions/79439012/how-do-i-create-a-self-joined-table-in-sqlalchemy-for-mysql[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия