Вылазит ошибка при создании таблицы, код вроде ничем не отличается от приведенного в документации. В чем ошибка?
Код:
engine = create_engine('mysql+pymysql://lab_6:lab_6@localhost:3306/lab_6', pool_recycle=3600)
connection = engine.connect()
metadata = MetaData()
regions = table('regions', metadata,
Column('region_id', Integer(), primary_key=True),
Column('region_name', String(45), index=True, nullable=False, unique=True),
Column('region_population', Integer(), nullable=False),
Column('region_square', Integer(), nullable=False)
)
cities = table('cities', metadata,
Column('city_id', Integer(), primary_key=True),
Column('city_name', String(45), nullable=False, unique=True),
Column('region_id', Integer(), ForeignKey('regions.region_id'))
)
metadata.create_all(engine)
Ошибка:
C:\Program Files (x86)\Python\lib\site-packages\pymysql\cursors.py:166: Warning: (1366, "Incorrect string value: '\\xE7\\xE8\\xEC\\xE0)' for column 'VARIABLE_VALUE' at row 480")
result = self._query(query)
C:\Program Files (x86)\Python\lib\site-packages\pymysql\cursors.py:166: Warning: (1287, "'@@tx_isolation' is deprecated and will be removed in a future release. Please use '@@transaction_isolation' instead")
result = self._query(query)
Traceback (most recent call last):
File "D:/projects/labs/Новая папка/Lab_6.py", line 36, in <module>
Column('region_square', Integer(), nullable=False)
File "<string>", line 2, in table
File "C:\Program Files (x86)\Python\lib\site-packages\sqlalchemy\sql\selectable.py", line 1720, in __init__
self.append_column(c)
File "C:\Program Files (x86)\Python\lib\site-packages\sqlalchemy\sql\selectable.py", line 1733, in append_column
self._columns[c.key] = c
AttributeError: 'MetaData' object has no attribute 'key'