简体   繁体   English

类似数据库的操作,无需使用任何数据库

[英]Database-like operations without any database use

I have been given a few TSV files containing data, around 800MB total in a couple of files. 我得到了一些包含数据的TSV文件,其中几个文件总共约800MB。 Each of them has columns that link up with columns in another file. 它们每个都有与另一个文件中的列链接的列。

I have so far imported all of my data into Python and stored it in an array. 到目前为止,我已将所有数据导入Python并将其存储在数组中。 I now need to find a way to build a database out of this data without using any SQL, NoSQL, etc. 现在,我需要找到一种无需使用任何SQL,NoSQL等即可从该数据构建数据库的方法。

In the end I will be performing SQL-like queries on it (without SQL) and performing OLAP operations on the data. 最后,我将在其上执行类似SQL的查询(不使用SQL),并对数据执行OLAP操作。 I can also NOT use any external libraries. 我也不能使用任何外部库。

After doing some research, I have came across using dictionaries as a way to do this project, but I am not sure how to go about linking the tables together with dictionary. 在进行了一些研究之后,我发现使用字典作为执行此项目的一种方法,但是我不确定如何将表与字典链接在一起。 Would it be a list of dictionaries? 它会是字典清单吗?

Yes, you could fake a lot of DB operations with a nested dict structure. 是的,您可以使用嵌套的dict结构伪造许多数据库操作。 Top level is your "tables", each table has entries (use a "primary key" on these) and each entry is a dict of key:value pairs where keys are "column names" and values are, well, values. 顶层是您的“表”,每个表都有条目(在这些表上使用“主键”),每个条目都是key:value对的字典,其中键是“列名”,值是值。

You could even write a little sql-like query language on this if you wanted, but you'd want to start by writing some code to manage this. 如果愿意,您甚至可以在上面写一些类似于sql的查询语言,但是您首先要编写一些代码来管理它。 You don't want to be building this DB freehand, it'll be important to define the operations as code. 您不希望徒劳地构建此数据库,将操作定义为代码很重要。 For example, insert should deal with enforcing value restrictions and imposing defaults and setting auto-incrementing keys and so forth (if you really want to be "performing sql like queries" against it) 例如,insert应该处理强制值限制,强加默认值以及设置自动递增键等(如果您真的想对其执行“类似sql的查询”)

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

相关问题 可搜索的类似数据库的python对象结构? - Searchable database-like structure for python objects? 如何在python中保存大的“类数据库”类 - How to save big “database-like” class in python 可以只使用一个游标对数据库执行所有操作吗? - Is it okay to use only one cursor to execute all operations with database? 是否应将同一对象用于独立的不同数据库操作? - Should I use the same object for independent, different database operations? 查询数据库而无需任何迁移D​​jango - Query a database without any migrations Django django中有什么方法可以使用数据库而不创建models.py文件吗? - Is there any method in django to use database without creating models.py file? 在Python SQLAlchemy中使用数据库模型对象,而不会干扰数据库事务 - Use a database model object in Python SQLAlchemy without interfering with database transactions Django中用于相关操作的数据库事务 - database tranactions in django for dependent operations 如果在数据库(如MySQL)中有任何数据更新,是否可以触发脚本或程序? - Is it possible to trigger a script or program if any data is updated in a database, like MySQL? 有没有办法将 Python 可执行文件与数据库一起使用,而无需在目标 PC 上安装数据库? - Is there a way to use a Python executable with a database without installing a database on the target PC?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM