我正在从Instagram到电报机器人的集成工作,它将监视用户帐户和每一个新的职位,我会在电报通知.我正在为这个项目创建我的表,并坚持使用SQLAlchemy创建表,有人已经遇到了这些问题吗?
from sqlalchemy import Column, Integer, DateTime, Text, Boolean
from config import Base, engine
import uuid
class InstagramImageNoRss(Base):
__tablename__ = 'instagram_image_norss'
__table_args__ = {'sqlite_autoincrement': True}
id = Column(Text, primary_key=True, default=lambda: uuid.uuid4().hex)
local_path = Column(Text)
local_path_txt = Column(Text)
local_path_json = Column(Text)
comments_path = Column(Text)
geolocation_path = Column(Text)
text_data = Column(Text)
json_data = Column(Text)
comments_data = Column(Text)
geolocation_data = Column(Text)
username = Column(Text)
sended = Column(Boolean)
published = Column(DateTime)
publication_index = Column(Integer)
def __str__(self):
import json
return json.dumps(self.__dict__, default=str)
class InstgaramImageRss(Base):
__tablename__ = 'instagram_image_rss'
__table_args__ = {'sqlite_autoincrement': True}
id = Column(Text, primary_key=True, default=lambda: uuid.uuid4().hex)
published = Column(DateTime)
local_name = Column(Text)
local_path = Column(Text)
rss_webstagram_id = Column(Text)
summary = Column(Text)
media_url = Column(Text)
image_hash = Column(Text)
creation_time = Column(DateTime)
link = Column(Text)
sended = Column(Boolean)
username = Column(Text)
def __str__(self):
import json
return json.dumps(self.__dict__, default=str)
class InstagramSubscription(Base):
__tablename__ = 'instagram_subscription'
__table_args__ = {'sqlite_autoincrement': True}
id = Column(Text, primary_key=True, default=lambda: uuid.uuid4().hex)
username = Column(Text, primary_key=True, unique=True)
last_check_datetime = Column(DateTime)
subscribed = Column(Boolean)
def __str__(self):
import json
return json.dumps(self.__dict__, default=str, indent=4)
class Chat(Base):
__tablename__ = 'chats'
__table_args__ = {'sqlite_autoincrement': True}
id = Column(Text, primary_key=True, default=lambda: uuid.uuid4().hex)
chat_id = Column(Integer)
admin = Column(Boolean)
tg_ans = Column(Text)
def __str__(self):
import json
return json.dumps(self.__dict__, default=str, indent=4)
# Error happens here
Base.metadata.create_all(engine)
我收到以下错误:类型错误:函数最多接受3个参数(给定4个)
目前使用的是SQLite33.37.2和PY3.11.1
根据要求,完全追溯错误:
File "/workspace/InstagramTelegramBot/InstagramBotDAO.py", line 76, in <module>
Base.metadata.create_all(engine)
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/sql/schema.py", line 5828, in create_all
bind._run_ddl_visitor(
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3242, in _run_ddl_visitor
with self.begin() as conn:
File "/home/ribeiroo/.pyenv/versions/3.11.1/lib/python3.11/contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3232, in begin
with self.connect() as conn:
^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3268, in connect
return self._connection_cls(self)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 145, in __init__
self._dbapi_connection = engine.raw_connection()
^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/engine/base.py", line 3292, in raw_connection
return self.pool.connect()
^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 421, in connect
return _ConnectionFairy._checkout(self, self._fairy)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 1269, in _checkout
fairy = _ConnectionRecord.checkout(pool)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 716, in checkout
rec = pool._do_get()
^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/impl.py", line 403, in _do_get
c = self._create_connection()
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 393, in _create_connection
return _ConnectionRecord(self)
^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 678, in __init__
self.__connect()
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/pool/base.py", line 916, in __connect
)._exec_w_sync_on_first_run(self.dbapi_connection, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/event/attr.py", line 473, in _exec_w_sync_on_first_run
self(*args, **kw)
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/event/attr.py", line 487, in __call__
fn(*args, **kw)
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/engine/create.py", line 704, in on_connect
do_on_connect(dbapi_connection)
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/pysqlcipher.py", line 145, in on_connect
super_on_connect(conn)
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 574, in connect
fn(conn)
File "/workspace/InstagramTelegramBot/.venv/lib/python3.11/site-packages/sqlalchemy/dialects/sqlite/pysqlite.py", line 557, in set_regexp
dbapi_connection.create_function(
TypeError: function takes at most 3 arguments (4 given)
1条答案
按热度按时间ovfsdjhp1#
我可以通过安装pysqlcipher并创建这样的引擎来重现这个错误:
如果我安装sqlcipher3驱动程序,则不会发生错误。