简体   繁体   English

Python 3:存储数据而不将其加载到内存中

[英]Python 3 : Storing Data without loading it into memory

I am currently building a flask app that will have lots of data that I think I cannot load into memory.我目前正在构建一个 Flask 应用程序,其中包含大量我认为无法加载到内存中的数据。 I have searched many places, and have found the SQL seems to be a good solution.我搜索了很多地方,发现 SQL 似乎是一个很好的解决方案。 Sadly I cannot use SQL for this project due to some limitations of SQL.遗憾的是,由于 SQL 的一些限制,我无法在这个项目中使用 SQL。

My project consists many entries of我的项目包括许多条目

database[lookupkey1][lookupkey2]...and more lookup keys

My current plan is to override __getitem__ and __setitem__ and __delitem__ and replace them with calls to the database.我目前的计划是覆盖 __getitem__ 和 __setitem__ 和 __delitem__ 并将它们替换为对数据库的调用。 Is their any kind of database that can store large amounts of maps/dictionaries like他们的任何类型的数据库都可以存储大量地图/字典,例如

{"spam":{"bar":["foo","test"],"foo":["bar"]}}

I am also currently using JSON to save data, so it would be appreciated if the database had a easy way to migrate my current database.我目前也在使用 JSON 来保存数据,所以如果数据库有一种简单的方法来迁移我当前的数据库,我将不胜感激。

Sorry that I'm not very good at writing stack overflow questions.抱歉,我不太擅长编写堆栈溢出问题。

Most document-oriented DBs like MongoDB would allow you to save data as nested dict-list-like objects and query them using their keys and indexes.大多数面向文档的数据库(如 MongoDB)允许您将数据保存为嵌套的类似 dict-list 的对象,并使用它们的键和索引查询它们。

PS Accessing such a DB through a Python's dict accessors is a bad idea as it would produce a redundant DB query for each step which is highly ineffective and may lead to performance problems. PS 通过 Python 的 dict 访问器访问这样的数据库是一个坏主意,因为它会为每个步骤产生一个冗余的数据库查询,这是非常低效的,并可能导致性能问题。 Try looking at ORM for a DB you choose as most ORMs would allow you to access document-oriented DB's data in a way similar to accessing dicts and lists.尝试查看您选择的 DB 的 ORM,因为大多数 ORM 允许您以类似于访问字典和列表的方式访问面向文档的 DB 数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 python 中的文件读取某些行而不将其加载到 memory - Reading certain lines from a file in python without loading it in memory 按日期对 Python 中的巨大 cvs 进行排序,而不将其全部加载到内存中 - Sort huge cvs in Python by date without loading it all into memory 如何在 python 中跟踪一个大文件而不将其全部加载到 memory 中? - How to follow a large file in python without loading it all in the memory? 从 csv 中提取元数据而不在 python 中加载数据 - Extracting metadata from csv without loading data in python Python - 如何在不立即将整个文件加载到内存中的情况下发送带有附件的电子邮件? - Python - How to send an email with attachment without loading the whole file into memory at once? 在python中存储大型但可预测的数据 - Storing large but predictable data in python 使用Python在文本文件中存储数据 - Storing Data With Python in Text Files 从文件中读取特定数量的行而不存储在 memory 中? - Reading a specific number of lines from a file without storing in memory? Zip memory 中的多个目录和文件而不在磁盘上存储 zip - Zip multiple directories and files in memory without storing zip on disk 解析 Python 中的复杂 JSON 而不存储在文件中 - Parse the complex JSON in Python without storing in File
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM