import sys
sys.path.append('/Volumes/Sandisk/Projects/bravaorm')
import bravaorm
from model import *
import logging

def test():
    conn = bravaorm.Connection(db_user="root", db_password="root", db_host="localhost", db_port=3306, db_database="gofans", log_level="Debug")
    
    # Prepare test directly
    cursor = conn._conn.cursor
    stmt = "INSERT INTO blackwords (id, bla_word) VALUES (%(id)s, %(bla_word)s) ON DUPLICATE KEY UPDATE id=VALUES(id), bla_word=VALUES(bla_word)"
    data = [{'id': 34, 'bla_word': 'changed1'}, {'id': 35, 'bla_word': 'changed2'}]
    
    try:
        cursor.executemany(stmt, data)
        print("Executed statement:", cursor.statement)
        conn._conn.commit()
    except Exception as e:
        print("Error:", e)
        
    print("rowcount", cursor.rowcount)
    print("lastrowid", cursor.lastrowid)
    
    # Verify
    cursor.execute("SELECT * FROM blackwords WHERE id IN (34, 35)")
    print(cursor.fetchall())
    conn.close()

if __name__ == "__main__":
    test()
