this makes viewing diffs much nicer. If you add or remove a single column, you can easily see what was changed
2016-07-20 20236, 2016
armalcolite
ah, i have to move items in separate lines.
2016-07-20 20236, 2016
alastairp
by adding the comma to the beginning of a line, it means that when adding a column you only change one line, not two
2016-07-20 20251, 2016
alastairp
the same with every clause in the WHERE
2016-07-20 20200, 2016
armalcolite
sure. I'll make these changes across the PR's
2016-07-20 20205, 2016
alastairp
note also that instead of "select * from a,b WHERE a.id=b.id" I used a JOIN
2016-07-20 20218, 2016
alastairp
technically in postgresql there is no difference between these two forms
2016-07-20 20221, 2016
armalcolite
yeah, i noticed it today.
2016-07-20 20229, 2016
alastairp
but again, for consistency, we should use a single form in all of our code
2016-07-20 20254, 2016
alastairp
because your column names are the same, you can use USING (id) instead of a separate ON listen.id=listen_json.id clause
2016-07-20 20255, 2016
armalcolite
though, WHERE clause seems much more intuitive. But yes, consistency is must.
2016-07-20 20214, 2016
alastairp
I used to write with FROM/WHERE clauses
2016-07-20 20244, 2016
alastairp
but when I started using different join clauses (especially LEFT JOIN), it started making more sense to me to be consistent on what what effectively the same operation
2016-07-20 20255, 2016
alastairp
one more thing,
2016-07-20 20222, 2016
alastairp
we use the sqlalchemy text() helper in acousticbrainz (you can see it in the other example I linked to)
2016-07-20 20229, 2016
alastairp
this means that placeholders are like :this
2016-07-20 20253, 2016
armalcolite
even i have used it a lot of places.
2016-07-20 20258, 2016
alastairp
and then you pass a dictionary as the second argument to connection.execute
2016-07-20 20214, 2016
armalcolite
consistency again, i have used dict as well at many places.
2016-07-20 20219, 2016
alastairp
please make the query a separate string: query = text("""select...""")
2016-07-20 20226, 2016
alastairp
and then the actual query in a separate line
2016-07-20 20228, 2016
alastairp
for readability
2016-07-20 20249, 2016
alastairp
unfortunately none of these guidelines are written down. it's something that we should do in the future
2016-07-20 20257, 2016
Gentlecat
or just put it into an execute call
2016-07-20 20227, 2016
JesseW has quit
2016-07-20 20234, 2016
armalcolite
my lastest commit put it directly in the execute call.
2016-07-20 20240, 2016
armalcolite
*latest
2016-07-20 20248, 2016
alastairp
for multiple line queries I don't like putting them directly in the execute call
for now I can make a screen and run it as the acousticbrainz user. this means that only I'll be able to connect to the screen though
2016-07-20 20229, 2016
KodeStar
it's not mb related, but making my head hurt, does anyone have any thoughts on storing a phash or libpuzzle hash and then using postgres to calculate the hamming distance?
2016-07-20 20212, 2016
alastairp
Gentlecat: when was the last time we made the virtualenv for the AB user?
2016-07-20 20218, 2016
alastairp
it has no gaia
2016-07-20 20249, 2016
Gentlecat
don't remember
2016-07-20 20226, 2016
alastairp
there's a gaia dir in ~acousticbrainz, I'll reinstall into the ve