A project for importing dump from StackOverflow into a database. Right now supports SQLITE and POSTGRES.
-
First download all
*.stackoverflow.com.7zfrile from https://archive.org/download/stackexchange/. -
Extract
7zfiles and put the extractedxmlfiles inside the ./inputs folder. -
It supports the following data at the moment:
First, navigate to your project's root directory in your terminal. Then, create a virtual environment named venv (or another name of your choice) by running:
python -m venv venv
This command creates a new directory named venv in your project directory, which contains a copy of the Python interpreter, the standard library, and various supporting files.
Before you can start installing packages, you need to activate the virtual environment. Activation will ensure that the Python interpreter and tools within the virtual environment are used in preference to the system-wide Python installation.
- On macOS and Linux:
source venv/bin/activate
- On Windows (cmd.exe):
.\venv\Scripts\activate.bat
- On Windows (PowerShell) or VSC Terminal:
.\venv\Scripts\Activate.ps1
Once activated, your terminal prompt must change to indicate that the virtual environment is active.
With the virtual environment activated, install the dependencies listed in requirements.txt by running:
pip install -r requirements.txt
Or you can install them directly. Ensure you have the following installed in your Python environment. If not, you can install them using pip:
pip install python-dotenv
pip install colored
pip install psycopg2-binary
pip install markdownify
pip install beautifulsoup4 html2text
Copy and paste the .env.example file and rename the new file to .env.
Edit the .env file as following:
- Make a StackExchange application and copy and paste the application key as
APP_KEY - Make sure that you sellect the right DBMS type. If you want Sqlite the keep
SQLITEotherwise if you want Postgres keepPOSTGRES DB_PATHis needed for Sqlite and otherDB_*attributes are needed for Postgres databases.
Run the main.py file to run the program.
python main.pyRun with arguments:
python main.py --input_file_path "C:\Users\mahdi\Git\GitHub\StackOverflowDumpReader\inputs\Tags.xml" --destination_table "Tags" --start_line_number 1 --convert_to_md True