From: Frank Brehm Date: Fri, 12 Jan 2018 11:54:17 +0000 (+0100) Subject: Inserting new admin users X-Git-Tag: 0.1.2~50 X-Git-Url: https://git.uhu-banane.net/?a=commitdiff_plain;h=444878dbf3a8d7401d2186bdfcb57564b1a7ab8a;p=pixelpark%2Fadmin-tools.git Inserting new admin users --- diff --git a/pp_lib/dnsui_users.py b/pp_lib/dnsui_users.py index 362c71e..0c04368 100644 --- a/pp_lib/dnsui_users.py +++ b/pp_lib/dnsui_users.py @@ -25,7 +25,7 @@ from .common import pp from .ldap_app import PpLdapAppError, PpLdapApplication -__version__ = '0.4.1' +__version__ = '0.4.2' LOG = logging.getLogger(__name__) @@ -507,6 +507,23 @@ class DnsuiUsersApp(PpLdapApplication): if self.verbose > 1: LOG.debug("User data to insert:\n{}".format(pp(self.users_to_add))) + sql = textwrap.dedent('''\ + INSERT INTO public.user (uid, name, email, active, admin, developer) + VALUES (%(uid)s, %(name)s, %(email)s, %(active)s, %(admin)s, %(developer)s) + ''').strip() + if self.verbose > 1: + LOG.debug("Insert SQL:\n{}".format(sql)) + + with self.db_connection.cursor() as db_cursor: + + for db_user in self.users_to_add: + + if self.verbose > 1: + show_sql = db_cursor.mogrify(sql, db_user) + LOG.debug("Executing:\n{}".format(show_sql)) + if not self.simulate: + db_cursor.execute(sql, db_user) + # ------------------------------------------------------------------------- def change_db_users(self):