Python Persistent Variable In Function In Sql