A Python script to import user data.
- Clone the repository:
git clone https://github.com/abiram31/import-users.git- Ensure you have Python 3.8+ installed.
--users: Path to the useraccounts csv file--passwords: Path to the passwords csv file--schema: Path to the sql file with users schema--emailsuffix: email suffix to be added after username (e.g.@clearcable.ca)--accountprefix: prefix to be added before account number (e.g.001-)
Run the script with:
python import_users.py --users <users.csv> --passwords <passwords.csv> --schema <schema.sql> --emailsuffix <emailsuffix> --accountprefix <accountprefix>example bash:
python import_users.py --users useraccounts.csv --passwords passwords.csv --schema createUsersTable.sql --emailsuffix @clearcable.ca --accountprefix 001-example bash using uv:
uv run python import_users.py --users useraccounts.csv --passwords passwords.csv --schema createUsersTable.sql --emailsuffix @clearcable.ca --accountprefix 001-- If a username doesnt have a corresponding password in the passwords file, the password is set to null in the database
- If a user exists in the passsword file, but is not in the users file, the user is added to the database with null as the value for accountnumber, email, phonenumber and address
- The username column name is the same in both CSV files
- The files may be very large, so avoided saving to memory
- the 2 csv files, schema, the email suffix and the account prefix is required
Required columns:
accountnumber, Username, phonenumber, addressRequired columns:
Username, Password