Answer the question
In order to leave comments, you need to log in
Python does not save changes to the database when importing a function?
there is a file
a.py -> there is a function in it:
def myfunc( url, browser, db):
"""
browser = webdriver.Chrome as browser
url - какую страницу открываем в браузере
скрапим данные, обрабатываем и записываем в базу
db - база sqlite3
db.commit()
всё работает прекрасно
"""
pass
from a import myfunc
db = sqlite3.connect('./db.db')
cur = db.cursor()
url = http://someurl.com
with webdriver.Chrome as browser:
myfunc(url, browser, db)
Answer the question
In order to leave comments, you need to log in
so you
only have a comment in your function, pass and nothing else
if you have it that way, then everything is logical that you wrote the function and executed
if not, then show the real code
, and you still have a context manager up to the function itself, it can generally not reach
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question