Page 4 of 10

Export SQLite table to CSV

A number of times I’ve needed to export a specific table from an SQLite database to a CSV file.

The sqlite program itself gives a very clean interface for this.

sqlite3 -header -csv database.sqlite "SELECT * FROM artists;" > ./artists.csv

Conversely, if I need do this from the SQLite prompt, I need to do it slightly differently.

Continue reading

mesg: ttyname failed: Inappropriate ioctl for device

While running a cron job in Linux, I sometimes get this error and I had been struggling to solve this until I came across this post.

Although that particular post mentions the cause being Vagrant, mine was due to a cron job.

First the solution …

Modify .profile under home folder

Open ~/.profile

Replace the following line –

mesg n || true

with

tty -s && mesg n

The reason for this is given very well in the post linked above.

Continue reading

Postgres DB migration error due to replication

We got a weird error today when running the latest migration on a production Postgres DB.

cannot update table "schema_info" because it does not have a replica identity and publishes updates

The table schema_info is created when we run ruby Sequel migrations. This table stores just the version number of the latest migration applied under a column called version.

We had set up a replica database some time ago and it looked like the issue was because of this.

Continue reading

Disable specific default Windows key shortcuts

A number of times, I prefer to use the Windows key on the keyboard to create shortcuts, especially to applications which I use frequently.

However, Windows has a default set of keyboard shortcuts that it maps to various applications and those key mappings can’t be changed. A few examples are Cortana (Win+C), Clipboard (Win+V).

To get around this, the Registry Editor needs to be modified.

Continue reading

users and sudo in Linux

Every time I need to create, modify, grant sudo access to users in Linux, I have to search for it.

This is a list of the commands I’ve used in the past.

Will keep updating this so that I don’t have to load a search page every time!

All commands below are run as root user. If I’m not the root user, I need to prefix them with sudo!

Continue reading

Postgres authentication

Reference: Stackoverflow

pg_hba.conf controls the authentication method. If you want to request a password, use md5 authentication. If you want to allow login with no password to anyone, use trust. If you want to require the same username in the operating system as in PostgreSQL, use peer (UNIX, only for local connections) or sspi (Windows).

If there’s a password set, but pg_hba.conf doesn’t tell PostgreSQL to ask for it, the password is ignored.

If pg_hba.conf tells PostgreSQL to ask for a password but there’s none set, then all login attempts will fail no matter what password is supplied.

Create Postgres replica on separate server over the network

A database replica is able to provide another layer of protection in case of the main database server going down.

Postgres has this capability out of the box.

In this case the requirement was to create a replica on a separate server. (It’s also possible to create it on the same server where Postgres is running).

The replica maintains an exact copy of the main database (called Primary) on a real-time basis.

Continue reading

Copyright © 2024 the möbius trip

Theme by Anders NorenUp ↑