Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python SqlAlchemy/Sqlite:InterfaceError-是否有数据大小限制?_Python_Sqlite_Sqlalchemy_Python 3.4 - Fatal编程技术网

Python SqlAlchemy/Sqlite:InterfaceError-是否有数据大小限制?

Python SqlAlchemy/Sqlite:InterfaceError-是否有数据大小限制?,python,sqlite,sqlalchemy,python-3.4,Python,Sqlite,Sqlalchemy,Python 3.4,我尝试使用SqlAlchemy将(公认非常大的)BLOB存储到sqlite数据库中 对于我使用ubuntu-14.04.2-desktop-amd64.iso作为我想要存储的BLOB。其大小: $ ls -lhubuntu-14.04.2-desktop-amd64.iso ... 996M ... ubuntu-14.04.2-desktop-amd64.iso 代码 from pathlib import Path from sqlalchemy import (Column, Integ

我尝试使用SqlAlchemy将(公认非常大的)BLOB存储到sqlite数据库中

对于我使用
ubuntu-14.04.2-desktop-amd64.iso
作为我想要存储的BLOB。其大小:

$ ls -lhubuntu-14.04.2-desktop-amd64.iso
... 996M ... ubuntu-14.04.2-desktop-amd64.iso
代码

from pathlib import Path
from sqlalchemy import (Column, Integer, String, BLOB, create_engine)
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker
from sqlite3 import dbapi2 as sqlite

SA_BASE = declarative_base()

class DbPath(SA_BASE):

    __tablename__ = 'file'

    pk_path = Column(Integer, primary_key=True)
    path = Column(String)
    data = Column(BLOB, default=None)

def create_session(db_path):

    db_url = 'sqlite+pysqlite:///{}'.format(db_path)
    engine = create_engine(db_url, module=sqlite)
    SA_BASE.metadata.create_all(engine)
    session = sessionmaker(bind=engine)

    return session()

if __name__ == '__main__':  

    pth = Path('/home/user/Downloads/iso/ubuntu-14.04.2-desktop-amd64.iso')

    with pth.open('rb') as file_pointer:
        iso_data = file_pointer.read()
    db_pth = DbPath(path=str(pth), data=iso_data)    
    db_session = create_session('test.sqlite')
    db_session.add(db_pth)
    db_session.commit()
运行此命令会引发错误

InterfaceError: (InterfaceError) Error binding parameter 1 - probably unsupported
  type. 'INSERT INTO file (path, data) VALUES (?, ?)' 
  ('/home/user/Downloads/iso/ubuntu-14.04.2-desktop-amd64.iso', <memory 
  at 0x7faf37cc18e0>)
是否有数据大小限制?或者,当文件大小超过某个限制时,我需要做些什么


不管关于限制的答案是什么:我感兴趣的是如何使用SqlAlchemy将这种大小的文件存储到sqlite中?

这是一个非常大的blob,即使对于非嵌入式DBs来说也是如此,因为它们通常会存储在单独的文件中。。。为什么不将文件存储在文件系统上,并将该文件的路径存储在sqlite中呢?是的,我可以将文件存储在文件系统中(通常我会)。但这次我想(ab)使用sqlite作为文件同步工具的包文件格式。我希望我可以将所有关于新文件和要删除的文件的信息打包到一个文件中(是的,我也可以做一些类似于.deb包的事情,但sqlite似乎更简单);它抱怨这种类型。这就是让我感到困惑的地方。这是一个非常大的blob,即使对于非嵌入式DBs来说也是如此,因为它通常会存储在一个或多个单独的文件中。。。为什么不将文件存储在文件系统上,并将该文件的路径存储在sqlite中呢?是的,我可以将文件存储在文件系统中(通常我会)。但这次我想(ab)使用sqlite作为文件同步工具的包文件格式。我希望我可以将所有关于新文件和要删除的文件的信息打包到一个文件中(是的,我也可以做一些类似于.deb包的事情,但sqlite似乎更简单);它抱怨这种类型。这就是让我难堪的地方。
$ ls -lh ubuntu-14.04.2-server-amd64.iso
... 595M ... ubuntu-14.04.2-server-amd64.iso