Python Forum
Link scripts from a different folder
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Link scripts from a different folder
#1
Hello,

I have a folder called "Inventory system" and within the "Inventory System" folder I have 2 subfolders: "Databases" and "Functions"

The "Databases" stores my .db files and the "Functions" folder stores all the functions that I call in my main script (My main script is located in the "Inventory System" folder).

I'm wondering if it's possible for my main script to call all those files from those different folders. I know I need an import statement, but where/how do I provide the paths for the folders?

My Main.py import statements:
#-----------------------------------------------
from /Databases/UserDatabase import *
from /Functions/CreateItemsTable import createDatabase
from /Functions/AddInventory import addInventory
#---------------------------------------------------------------
And how would I connect to the inventory.db since it's in the "Databases" folder and this chunk of code is from one of my Functions (located in the "Functions" folder)
    #Connect to the inventory database (inventory.db)
    connection = sqlite3.connect("inventory.db")
    cursor = connection.cursor()
Thanks in advance.
Reply


Messages In This Thread
Link scripts from a different folder - by Extra - May-11-2022, 08:00 PM
RE: Link scripts from a different folder - by Extra - May-11-2022, 08:32 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Compare folder A and subfolder B and display files that are in folder A but not in su Melcu54 3 709 Jan-05-2024, 05:16 PM
Last Post: Pedroski55
  Compare filename with folder name and copy matching files into a particular folder shantanu97 2 4,690 Dec-18-2021, 09:32 PM
Last Post: Larz60+
  How to run an exe file in the Scripts folder using py.exe? quazirfan 2 3,065 Sep-08-2021, 01:00 AM
Last Post: quazirfan
  Move file from one folder to another folder with timestamp added end of file shantanu97 0 2,569 Mar-22-2021, 10:59 AM
Last Post: shantanu97
  Python Cut/Copy paste file from folder to another folder rdDrp 4 5,267 Aug-19-2020, 12:40 PM
Last Post: rdDrp
  Delete directories in folder is not working after folder is updated asheru93 2 2,735 Feb-13-2019, 12:37 PM
Last Post: asheru93
  copy content of folder to existing folder shlomi27 0 2,705 Aug-11-2018, 01:44 PM
Last Post: shlomi27
  How to link two python scripts berthenet 35 90,351 Feb-03-2018, 02:24 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020