lsst-uk / lasair-lsst

Apache License 2.0
0 stars 0 forks source link

Filter node transfer to database #121

Closed RoyWilliams closed 5 months ago

RoyWilliams commented 5 months ago

There are two methods to transfer the local database from filter node to main database. See pipeline/filter/filtercore.py

In many ways it would be better and cleaner to use the client, but it needs some work on access permissions,

gpfrancis commented 5 months ago

For reference this test code works:

import mysql.connector

config = {
    'user': 'dbtest',
    'password': 'password',
    'host': '127.0.0.1',
    'database': 'dbtest',
    'allow_local_infile': True
}

query = "LOAD DATA LOCAL INFILE '/var/lib/mysql/testing.txt' REPLACE INTO TABLE testing2 FIELDS TERMINATED BY ',' ENCLOSED BY '\"' LINES TERMINATED BY '\n'"

cnx = mysql.connector.connect(**config)
cursor = cnx.cursor(buffered=True)
cursor.execute(query)
cursor.close()
cnx.commit()