It looks like you want to serialize the results of ScriptA, save it in a file or database somewhere, then try ScriptB to read these results (maybe also modify the file or update the database record to indicate that these results were processed).
, ScriptA ScriptB, ... , , ScriptB , , ScriptA (, , ScriptA , , ScriptB ).
, ScriptA ScriptB , . DRY. , . (, ... , , import ... - , / ( , , , ) . , ( ), script.
, ... .
, , SQLite3. , over-kill SQL- . SQLite3 Python .
pickle JSON YAML ( )... , - struct. , , . JSON . , , , ScriptA ScriptB (, , , - ) .
SQLite3 , , concurrency . (, ScriptA "--initdb" , ). , :
import sqlite3
db = sqlite3.connect('./foo.db')
cur = db.cursor()
results = cur.execute(SELECT value, MAX(date) FROM results').fetchone()[0]
... :
with db:
cur.execute('INSERT INTO results (value) VALUES (?)', (myvalue,))
, - (foo.db ) - :
with db:
cur.execute('CREATE TABLE IF NOT EXISTS results (value INTEGER NOT NULL, date TIMESTAMP DEFAULT current_timestamp)')
( , , ).
, , JSON. SQLite3 ACID () , .
, . , , . , , "" :
with db:
cur.execute('DELETE FROM results where date < ?', cur.execute('SELECT MAX(date) from results').fetchone())
, , INSERT UPDATE, :
with db:
cur.execute(cur.execute('UPDATE results SET value=(?)', (mynewvalue,))
( , (mynewvalue,) . DBAPI , , , , ).
, UPDATE, "date" "results" MAX(data) .
, . , , ScriptB , ScriptA , , ).