I am creating a simple network monitoring web application in Python.
Given:
Questions:
How should I store that textarea (python function) in the SQLite database?
How do I call that function from another python script after I've pulled it out of the SQLite database?
SQLite TEXT field is fine for that. And you can call function from the code like this:
>>> code = """
... def hello():
... print 'Hello world'
... """
>>> exec code
>>> hello()
Hello world
But I suggest you to save the code on disk with random filename. Then filename can be saved in database and code can be used like a normal module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With