0

I have MariaDB/HeidiSQL instance and in it I have a table which contains the values (1, print('Hello World!'). The first number is just an Id.

So my question is can I access this Python script with my pycharm and run it?

Is it possible to store python scripts into a DB and the run them in pycharm, with some sort of query?

Kape1
  • 11
  • 1
  • 1
  • Possibly related: [How do I execute a string containing Python code in Python?](https://stackoverflow.com/questions/701802/how-do-i-execute-a-string-containing-python-code-in-python). Get what you need from the database and then execute it that way. – Lomtrur Sep 20 '17 at 15:30
  • Can you please provide a valid usecase for storing your code in a database? – Klaus D. Sep 20 '17 at 15:30
  • Probably an answer in here: https://stackoverflow.com/q/701802/1531971 –  Sep 20 '17 at 15:39
  • 2
    Possible duplicate of [How do I execute a string containing Python code in Python?](https://stackoverflow.com/questions/701802/how-do-i-execute-a-string-containing-python-code-in-python) – tk421 Sep 20 '17 at 16:10

1 Answers1

1

Just write a python script which connects to your database using a client and fetch the target script as string.
How to execute a string in python as code is explained in the question How do I execute a string containing Python code in Python?

Jo.
  • 778
  • 1
  • 12
  • 17
  • What I did was this: cur = db.cursor() cur.execute("SELECT Script FROM Game") db.commit() result = str(cur.fetchone()) mycode = result[2:23] exec(mycode) db.close() – Kape1 Sep 20 '17 at 18:49