<commit_before>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

app = Flask(__name__)
db = SQLAlchemy(app)

class User(db.Model):
    __bind_key__ = 'userdb'
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(80), unique=True)

    login_logs = db.relationship(lambda: LoginLog, backref='owner')


class LoginLog(db.Model):
    __bind_key__ = 'logdb'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey(User.id))
    ctime = db.Column(db.DateTime, default=datetime.now(), nullable=False)

if __name__ == '__main__':
    app.config['SQLALCHEMY_ECHO'] = True
    app.config['SQLALCHEMY_BINDS'] = {
        'userdb': 'sqlite:///./user.db',
        'logdb':  'sqlite:///./log.db', 
    }
        
    db.drop_all()
    db.create_all()

    user = User(nickname='jaru')
    db.session.add(user)

    login_log = LoginLog(owner=user)
    db.session.add(login_log)

    db.session.commit()
<commit_msg>+ 멀티 데이터베이스 바인딩 디비별 커밋<commit_after>from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from datetime import datetime

app = Flask(__name__)
db = SQLAlchemy(app)

class User(db.Model):
    __bind_key__ = 'userdb'
    id = db.Column(db.Integer, primary_key=True)
    nickname = db.Column(db.String(80), unique=True)

    login_logs = db.relationship(lambda: LoginLog, backref='owner')


class LoginLog(db.Model):
    __bind_key__ = 'logdb'
    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.Integer, db.ForeignKey(User.id))
    ctime = db.Column(db.DateTime, default=datetime.now(), nullable=False)

if __name__ == '__main__':
    app.config['SQLALCHEMY_ECHO'] = True
    app.config['SQLALCHEMY_BINDS'] = {
        'userdb': 'sqlite:///./user.db',
        'logdb':  'sqlite:///./log.db', 
    }
        
    db.drop_all()
    db.create_all()

    user = User(nickname='jaru')
    db.session.add(user)
    db.session.commit()

    login_log = LoginLog(owner=user)
    db.session.add(login_log)
    db.session.commit()

{'fraction_non_alphanumeric': 0.14705882352941177, 'fraction_numerical': 0.0019286403085824494, 'mean_word_length': 3.4719827586206895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '8259', 'n_tokens_mistral': 801, 'n_tokens_neox': 781, 'n_words': 132}