An Error in A Query Removed All Data

published at 28 Nov, 2017 by Szymon Lipiński tags: database postgresql sql

There Was an Error in a Good Query

After applying a data migration we had some duplicated rows in a table. I wrote a simple query for finding the duplicates and removing them from the table. All went fine. Or at least I thought so.

This kind of operations should always be done in a transaction, so the changes can be rolled back on error. The general workflow I use looks like this:

BEGIN;

DELETE FROM x...

SELECT * FROM x...

...

This leaves an open transaction, so I can check all the data without modifying them permanently in the database.

 

Why I Created DBRows

published at 15 Feb, 2017 by Szymon Lipiński tags: programming python

Some time ago I was using the Records library. When I searched for some comments, I noticed only good reviews. The main goal of this library to simplify things. It’s a proxy to the SqlAlchemy library.

The only thing I was no impressed with was the library interface.

After some time of using it, I got the feeling that the interface is not good enough. It looked rather like some random ad hoc bunch of functions put into classes.

So I have decided to implement my own version. Mainly to find out if it is possible to create the kind of interface I described here.

That’s why the DBRows Project has been born.

 

Good Python Interface

published at 24 Jan, 2017 by Szymon Lipiński tags: programming python java

In the previous blog post I wrote about changing interfaces using a Java class as an example.

The public interface of the final implementation was:

constructor:

    (int, int)

methods:
 
    getWidth() -> int
    getHeight() -> int
    getArea() -> int
    setWidth(int)
    setHeight(int) 

There were no public fields, all were accessible with the setters and getters.

There was also a C# example with the properties. This way I had the public interface like:

constructor:

    (int, int)

fields:

    int width
    int height

Because of the properties those fields were also writable.

 

Good Naming Things Is Hard

published at 23 Jan, 2017 by Szymon Lipiński tags: programming python java

Naming things is hard.

Usually when we are going to have a brand new kid, naming her/him takes a couple of months. The endless discussions, the sleepless nights, all the lists of possible combinations of letters (just assume only letters for now). And all the effort just to achieve something that would sound nice to us. And only to us, as usually the grandparents of that brand new family member will not be happy with our choice.

The normal baby delivery date is quite far in the future, so usually we have lots of time to think about the name and the possible problems the kid will have when naming like Donald Trump Otieno or like this:

delete from users