Skip to content

Instantly share code, notes, and snippets.

@alastair

alastair/db.py Secret

Created June 13, 2022 13:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alastair/51a27925b374f248134c1135a9286718 to your computer and use it in GitHub Desktop.
Save alastair/51a27925b374f248134c1135a9286718 to your computer and use it in GitHub Desktop.
import psycopg2
conn = psycopg2.connect(
host="localhost",
database="musicbrainz_db",
user="musicbrainz",
password="musicbrainz",
port=5432)
cursor = conn.cursor()
def check_in_recording(rec_mbid):
cursor.execute("SELECT gid FROM recording WHERE gid=%(id)s;", {'id':rec_mbid})
fetch = cursor.fetchone()
if type(fetch) == tuple:
return fetch[0]
else:
return None
import db
def test_check_in_recording():
recording = db.check_in_recording("4a039757-f00f-4a49-a2c2-1a92d92ea9e7")
assert recording is None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment