Programming thread

  • 📧 If you are an employee of a T1 ISP, US datacenter, or related company please get in touch at josh@kiwifarms.net. I have some questions.
  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
I just wish sqlite had a server-side version. I hate how other databases are so finicky.
Look, I like SQLite, but I wish it had a pragma that would make it more finicky by strictly enforcing the type declarations for each column. Dynamic typing is fine for simple shell scripts and such, but for more anything more complicated, or with higher demands for consistency, I want static typing (or at least dynamic typing with type checks performed as early as possible).

Yes, I know that I can write a redundant abomination like
SQL:
CREATE TABLE IF NOT EXISTS employees (
    id INTEGER PRIMARY KEY,
    firstname TEXT NOT NULL,
    lastname TEXT NOT NULL,
    ssn CHAR(11) NOT NULL,
    CONSTRAINT ck_firstname_type
        CHECK (TYPEOF(firstname) = 'text'),  -- should be automatic
    CONSTRAINT ck_lastname_type
        CHECK (TYPEOF(lastname) = 'text'),  -- should be automatic
    CONSTRAINT ck_ssn_type
        CHECK (TYPEOF(ssn) = 'text' AND LENGTH(ssn) = 11),  -- should be automatic
    CONSTRAINT ck_ssn_format
        CHECK (ssn REGEXP '[0-9]{3}-[0-9]{2}-[0-9]{4}')
);
but I really shouldn't have to, as it's tedious and error-prone. I don't expect the feature to be added, so I'll probably (eventually) write a program that parses table declarations, interprets the column types, and spits out equivalent declarations with type-checking constraints added. (Writing a program generator is the White workaround to avoid tedious busywork code, compared to the Jeet workaround of giving the declarations to an LLM, telling it to do the needful, and hoping for the best.)
 
but I really shouldn't have to, as it's tedious and error-prone.
Personally, I want the error checking to be on me and my program. If I'm retarded enough to insert a bitmap in an int then it's on me. SQLite "allows" it and it becomes my problem later on. Meanwhile other database engines require different types for something like date vs datetime vs time vs string vs int as seconds. I don't like the database engine getting in my way of dealing with my own data.
Also I don't like how anti-agnostic other databases are. The column delimiter [column] vs ´column´ is extremely retarded. SQLite is one of the few engines that accepts various SQL standards without shitting on your face.
 
As great as SQLite is, I want to strangle the lunatic who came up with this shit. Read the page and weep.
Lunacy said:
Note that a declared type of "FLOATING POINT" would give INTEGER affinity, not REAL affinity, due to the "INT" at the end of "POINT". And the declared type of "STRING" has an affinity of NUMERIC, not TEXT.
 
Well I keep seeing more and more of these. As it turns out, Postgres is a Swiss army knife of sorts.




Disclaimer: I am an old school Sysadmin guy so databases are scary to me. I set them up but whatever happens in the instances is a black box to me.
 
Last edited:
Well I keep seeing more and more of these. As it turns out, Postgres is a Swiss army knife of sorts.

Disclaimer: I am an old school Sysadmin guy so databases are scary to me. I set them up but whatever happens in the instances is a black box to me.
Yes, and Sqlite is even more Swiss-army-ish. Postgres feels positively enterprise by comparison. They're both great tools, despite the glazing I'm about to give Sqlite.

Sqlite has started turning up in all kinds of places. The Minecraft-inspired Vintage Story uses Sqlite for chunk storage, and apparently it's faster than using the raw filesystem. Most of the top audio players have Sqlite backends for their music databases.

Postgres is a lot more monolithic, so if you have several apps accessing data, it's the way to go, as each Sqlite DB is separate.
 
Yes, and Sqlite is even more Swiss-army-ish. Postgres feels positively enterprise by comparison. They're both great tools, despite the glazing I'm about to give Sqlite.

Sqlite has started turning up in all kinds of places. The Minecraft-inspired Vintage Story uses Sqlite for chunk storage, and apparently it's faster than using the raw filesystem. Most of the top audio players have Sqlite backends for their music databases.

Postgres is a lot more monolithic, so if you have several apps accessing data, it's the way to go, as each Sqlite DB is separate.
This guy's channel is a treasure trove of Postgres content.


For a DB neophyte like me, these truth nukes are amazing.
 
XML:
<?xml type="database"?>
<database name="db">
    <table name="users">
        <row>
            <userid type="id" key>148886</userid>
            <name type="text">Rango Dango</name>
            <password type="text">hunter2</password>
            <messages type="number">9999</messages>
        </row>
    </table>
    <table name="messages">
        <row>
            <messageid type="id" key>982305</messageid>
            <author type="id" reltable="users" relcol="userid">14886</author>
            <content type="text">pee pee poo poo</content>
        </row>
    </table>
</database>
 
Last edited:
XML:
<?xml type="database"?>
<database name="db">
    <table name="users">
        <row>
            <userid type="id" key>14886</userid>
            <name type="text">Rango Dango</name>
            <password type="text">hunter2</password>
            <messages type="number">9999</messages>
        </row>
    </table>
    <table name="messages">
        <row>
            <messageid type="id" key>982305</messageid>
            <author type="id" reltable="users" relcol="userid">14886</author>
            <content type="text">pee pee poo poo</content>
        </row>
    </table>
</database>
That's awful, but at the height of XML Madness there was a blurb in the current events column of Dr. Dobb's Journal (remember that?) about X++, a project to reskin C++ in XML syntax. Fortunately for your sanity, ddj.com is now dead forever so I can't find the article short of going to the university library and combing through microfilm, and that's not going to happen any time soon. I assure you that the example code in the article was as awful as you'd expect it to be.
 
1781560138971.png

Microservices and its consequences have been a disaster for the human race.
 
Back
Top Bottom