import sys
sys.path.append('/Volumes/Sandisk/Projects/bravaorm')
import bravaorm
from model import *
import logging
conn = bravaorm.Connection(db_user="root", db_password="root", db_host="localhost", db_port=3306, db_database="gofans", log_level="Debug")

# Create object
b = Blackwords()
b.bla_word = "test_insert"
conn.add(b)
print("Saving INSERT...")
conn.save()
print(f"Inserted JSON: {b.toJSON()}")
print(f"Queue count after: {len(conn.__queue__['add'])}")

# Update object
b.bla_word = "test_update"
conn.add(b)
print("Saving UPDATE...")
conn.save()

# Verify
b2 = conn.blackwords.where(f"id={b.id}").all
print(f"Fetched JSON: {b2[0].toJSON()}")

conn.close()
