Better null display psql
- March 29, 2018
I’ve been frustating recently to differenciate NULL
and empty strings
in postgresql when requeting manually with psql
Turns out there’s an easy way to change that.
Just use
\pset null 'Ø'
and now
id | email | first | last
----+-------------------------+---------+-------
1 | your-email@example.com | Foo | Bar
2 | first-is-null@foo.com | |
will be
id | email | first | last
----+-------------------------+---------+-------
1 | your-email@example.com | Foo | Bar
2 | first-is-null@foo.com | Ø |
Read More
check start time before end time in postgresql
- August 10, 2016
get http status code in bash script wit curl
- July 29, 2016
some reading for better understanding of postgresql
- April 16, 2016
Today nothing big, just that I have a couple of links open on my firefox, that I plan to read when I have sometimes to learn more about postgresql, So here we are:
Read Morealembic use sql statement instead of sqlalchemy
- April 3, 2016
I know it’s pretty popular to use the wonderful sqlalchemy
ORM
for python, especially combined with alembic
, but sometimes
you just want to type plain SQL request.
And actually it’s pretty easy, after creating your migrations just do:
Read Morepython alembic with environment variables
- April 3, 2016
At my job we’re currently using alembic to manage our database migrations (i.e adding a new table / index etc.)
The tool is pretty mature and has been here for a while, so it covers a lot of advanced case (like handling several databases, having a tree of migrations etc.) while still being simple for simple case
The only not straighforward thing I found was that it’s not easy to integrate with 12Factor-apps, i.e my code is running in a lot of differents environments (vagrant+docker on my local machine, the QA environments, the pre-production, production etc.)
Read Morehow to sum all numbers in file in bash
- March 20, 2016
I have a file, with one number by line, how to get the sum
paste -s -d+ myfile_with_numbers | bc
and if you have a csv, delimited by ,
and for which the number is on
the 2nd field:
cut -d, my_file.csv -f 2 | paste -s -d+ | bc
Read More
murmur hash v3 in MySQL utf8 compatible
- March 20, 2016
Murmur hash v3 in MySQL utf8 compatible
These days for performance purpose, I needed to replace some autoincrement
Id
by a hash calculated one, in order to have a determinist way to retrieve from
an object, it’s record in database, and easily recognize duplicate.
For that I have chosen the murmur hash v3 function
For new records, I could use the python module (leveraging C code) mmh3
But as I needed to update million of existing record, I couldn’t possibly imagine doing that by calling a python script.
Read Morebug in Vagrant with Virtualbox sharefolder
- August 23, 2015
The problem: serving static files
The problem will affect you if you try to serve static files from your vagrant folder if you use the default from virtualbox
For example you got your nginx or apache to serve css files and when you update them, they don’t get updated, and sometimes they even come out with some garbage bytes at the end of it
Read Morecreate a rest api with symfony2 Part 2: Entity, DB Migration, CRUD
- May 24, 2015
Update 23 November 2015: Corrected some typo, and updated bundles versions for Doctrine
In the first part we’ve seen how to create the base of a symfony2 project used to generate a REST Api.
In this part we’re going to see
- How to use the basics of JMSSerializer to serialize Entity objects
- How to link our API with a database
- How to create migration files to easily manage our datase over time and colleagues
- and how to generate a full CRUD (create/read/update/delete) with form checking