uw.local.userdb package¶
Submodules¶
uw.local.userdb.setup_user module¶
User database setup program entry point.
Python process to set up databases for users and save passwords in .pgpass files.
-
class
uw.local.userdb.setup_user.
AdminCursor
(connection, cursor)[source]¶ Bases:
uw.local.dbtools.Cursor
-
get_fullname
(**parameters)¶
-
-
class
uw.local.userdb.setup_user.
UserDBCursor
(connection, cursor)[source]¶ Bases:
uw.local.dbtools.Cursor
-
create_user
(*parameters)¶
-
-
uw.local.userdb.setup_user.
create_user
(admin_cursor, userdb_cursor, userid)[source]¶ Set up the given userid with a role, database, and schema.
- Parameters
admin_cursor – DB connection cursor for obtaining the full name.
userdb_cursor – DB connection cursor for setting up role, database, and schema.
userid (str) – the userid to set up.
Obtain the user’s fullname from the WatIAM database, generate a random password, create the appropriate role, database, and schema, and return the password for storing in a .pgpass file. If the role already exists, return None instead.
-
uw.local.userdb.setup_user.
generate_password
()[source]¶ Generate a random password for a new user database account.
The password is a randomly-chosen string of 10 lowercase letters.
-
uw.local.userdb.setup_user.
main
()[source]¶ Main program for setting up calling user’s database, role, and schema.
-
uw.local.userdb.setup_user.
setup_user
(cursor, userid, fullname, password)[source]¶ Setup the given userid using the given password.
- Parameters
Creates the corresponding database and other setup steps. The database creation step requires that set_isolation_level be used to set isolation level 0 on the cursor’s connection, in order that the command can run outside of a transaction block.
Returns the request ID assigned by the database.
-
uw.local.userdb.setup_user.
write_pgpass
(hostname, port, userid, password)[source]¶ Write out password information to a .pgpass file.
- Parameters
Creates a new .pgpass file in ~userid containing a single line. Uses
pgpass_file_names()
to choose alternate filenames if necessary.