Live data from Hacker News

Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

github.com

51–60 of 82 posts

Re: Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

#53

Earlier quoted context omitted.

Yes. It's an interesting area, irrespective of implementation language. I had tried out one or two Java-based RDBMSes back in the day, via programs written in Java, for fun. I think one was HSQLDB. https://en.m.wikipedia.org/wiki/HSQLDB There was also another interesting one called PointBase, which was developed by Bruce Scott, an Oracle founder, and others. https://en.m.wikipedia.org/wiki/PointBase

H2 is pretty great and fully supports JSONB and the like [1]. Full java-only RDBMS. [1]: https://www.h2database.com/html/main.html

H2 is pretty solid. I used to ship a product with it as a default database. Customers could optionally use MySQL, MSSQL or Oracle, but for small businesses H2 was more than enough.

Re: Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

#55
post #51

long time ago the Python2 stdlib shipped a ton of DB libs like BerkelyDB. https://wiki.python.org/moin/BerkeleyDB

I was surprised to find out MicroPython had a database module based on Berkley DB in its standard library. It uses Berkley DB 1.x, which is the version of Berkley DB with a permissive license.

https://docs.micropython.org/en/v1.20.0/library/btree.html

Re: Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

#56
post #50
post #30

Earlier quoted context omitted.

That's pretty standard for parsing libraries - have you seen any good ones (for Python or other languages) that don't use a DSL like this? The only one I've seen is this one: https://parsy.readthedocs.io/en/latest/tutorial.html

Parse, comparse, parsec and PEGs come to mind. 1: https://github.com/massung/parse 2: https://wiki.call-cc.org/eggref/5/comparse 3: https://hackage.haskell.org/package/parsec 4: https://janet-lang.org/docs/peg.html

Here is another PEG one, though Guile allows expressing things as strings and as macro calls / s-expressions:

5: https://www.gnu.org/software/guile/manual/html_node/PEG-Pars...

Re: Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

#58

Thank you for sharing My perspective is that writing this kind of system in a language such as Python is actually a great thing because for myself Python is more widely readable and approachable compared to C++ or C which is what databases are often programmed in. If someone wants to be serious they can port it to a low level language . As it stands it's educational and useful for studying. I wrote a distributed pseu…

Idk. Python is just as bad as C / C++, with the downside that you cannot do much of the interesting stuff one would need to if they wanted to learn how to make databases, if they use Python.

Both C and Python are very "approachable" if you ignore the bad language design, inconsistencies and other "gotchas" and only take the "easy" parts, disregarding edge cases. However, with C you could at least have a fighting chance to learn how to do things right, but with Python you'll never even know what the real thing is like.

Re: Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

#59

Nice OP. How would you say this compares to the inbuilt 'sqlite3' module in Python? Is it more or less portable? Different features?

the `sqlite3` module provides an interface to `sqlite` (https://www.sqlite.org/index.html), so that comparison doesn't really make sense.

OP rewrote the actual database in Python, so (if it's a 1:1 equivalence), you would still use the python `sqlite3` module to connect to OP's project.

As mentioned, it's an educational project, not really meant to be used as a replacement for sqlite in projects etc though.

Re: Show HN: I wrote a RDBMS (SQLite clone) from scratch in pure Python

#60
post #13

Thanks to this post I learned about Lark, which looks like a really nice parser library for Python. The JSON tutorial on their site is excellent - shows how to build a basic parser for JSON, then goes into some great detail about how to improve its performance: https://lark-parser.readthedocs.io/en/latest/json_tutorial.h... Here's the grammar used for the RDBMS project: https://github.com/spandanb/learndb-py/blob/mas…

Not to be coy or disrespectful( and this is excellent work and a way to learn new things) but if one is generating a parser as a means to an end(the end being execution of the AST on the database), what are the learnings one gets from just the parser bit? Is it some kind of optimization you need to keep doing to the generated parser to make it more efficient?

Would a logical next step be Generate an optimal query plan from the AST(somehow..)?

Post reply on HN