[英]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.