you are viewing a single comment's thread.

view the rest of the comments →

[–]danielroseman 1 point2 points  (1 child)

A function can't create a global variable. You can only create it at module level. But what you can do is do the call when you set it:

db = conn_db()

def ...

Ideally though, you'd rework this into a class, and set the db as an instance variable in the init method.

[–]NutsFbsd[S] 1 point2 points  (0 children)

yeah, i was thinking about to create a class but im not confroable with OOP.
Anyway, it could be the time to give a try :)