def install_db(root_login="******", root_password=None, db_name=None, source_sql=None, admin_password=None, verbose=True, force=0, site_config=None, reinstall=False): make_conf(db_name, site_config=site_config) frappe.flags.in_install_db = True if reinstall: frappe.connect(db_name=db_name) dbman = DbManager(frappe.local.db) dbman.create_database(db_name) else: frappe.local.db = get_root_connection(root_login, root_password) frappe.local.session = frappe._dict({'user':'******'}) create_database_and_user(force, verbose) frappe.conf.admin_password = frappe.conf.admin_password or admin_password frappe.connect(db_name=db_name) check_if_ready_for_barracuda() import_db_from_sql(source_sql, verbose) remove_missing_apps() create_auth_table() create_list_settings_table() frappe.flags.in_install_db = False
def install_db(root_login="******", root_password=None, db_name=None, source_sql=None, admin_password=None, verbose=True, force=0, site_config=None, reinstall=False): make_conf(db_name, site_config=site_config) frappe.flags.in_install_db = True if reinstall: frappe.connect(db_name=db_name) dbman = DbManager(frappe.local.db) dbman.create_database(db_name) else: frappe.local.db = get_root_connection(root_login, root_password) frappe.local.session = frappe._dict({'user': '******'}) create_database_and_user(force, verbose) frappe.conf.admin_password = frappe.conf.admin_password or admin_password frappe.connect(db_name=db_name) check_if_ready_for_barracuda() import_db_from_sql(source_sql, verbose) remove_missing_apps() create_auth_table() create_list_settings_table() frappe.flags.in_install_db = False
def install_db(root_login="******", root_password=None, db_name=None, source_sql=None, admin_password=None, verbose=True, force=0, site_config=None, reinstall=False, no_mariadb_socket=False): make_conf(db_name, site_config=site_config) frappe.flags.in_install_db = True if reinstall: frappe.connect(db_name=db_name) dbman = DbManager(frappe.local.db) dbman.create_database(db_name) else: frappe.local.db = get_root_connection(root_login, root_password) frappe.local.session = frappe._dict({'user':'******'}) create_database_and_user(force, verbose, no_mariadb_socket) frappe.conf.admin_password = frappe.conf.admin_password or admin_password frappe.connect(db_name=db_name) check_if_ready_for_barracuda() import_db_from_sql(source_sql, verbose) if not 'tabDefaultValue' in frappe.db.get_tables(): print('''Database not installed, this can due to lack of permission, or that the database name exists. Check your mysql root password, or use --force to reinstall''') sys.exit(1) remove_missing_apps() create_auth_table() setup_global_search_table() create_user_settings_table() frappe.flags.in_install_db = False
def install_db(root_login="******", root_password=None, db_name=None, source_sql=None, admin_password=None, verbose=True, force=0, site_config=None, reinstall=False): make_conf(db_name, site_config=site_config) frappe.flags.in_install_db = True if reinstall: frappe.connect(db_name=db_name) dbman = DbManager(frappe.local.db) dbman.create_database(db_name) else: frappe.local.db = get_root_connection(root_login, root_password) frappe.local.session = frappe._dict({'user':'******'}) create_database_and_user(force, verbose) frappe.conf.admin_password = frappe.conf.admin_password or admin_password frappe.connect(db_name=db_name) check_if_ready_for_barracuda() import_db_from_sql(source_sql, verbose) if not 'tabDefaultValue' in frappe.db.get_tables(): print('''Database not installed, this can due to lack of permission, or that the database name exists. Check your mysql root password, or use --force to reinstall''') sys.exit(1) remove_missing_apps() create_auth_table() setup_global_search_table() create_user_settings_table() frappe.flags.in_install_db = False
def execute(): if '__OldAuth' not in frappe.db.get_tables(): frappe.db.sql_ddl('''alter table `__Auth` rename `__OldAuth`''') create_auth_table() # user passwords frappe.db.sql( '''insert ignore into `__Auth` (doctype, name, fieldname, `password`) (select 'User', user, 'password', `password` from `__OldAuth`)''') frappe.db.commit() # other password fields for doctype in frappe.db.sql_list( '''select distinct parent from `tabDocField` where fieldtype="Password" and parent != "User"'''): frappe.reload_doctype(doctype) meta = frappe.get_meta(doctype) for df in meta.get('fields', {'fieldtype': 'Password'}): if meta.issingle: password = frappe.db.get_value(doctype, doctype, df.fieldname) if password: set_encrypted_password(doctype, doctype, password, fieldname=df.fieldname) frappe.db.set_value(doctype, doctype, df.fieldname, '*' * len(password)) else: for d in frappe.db.sql( '''select name, `{fieldname}` from `tab{doctype}` where `{fieldname}` is not null'''.format(fieldname=df.fieldname, doctype=doctype), as_dict=True): set_encrypted_password(doctype, d.name, d.get(df.fieldname), fieldname=df.fieldname) frappe.db.sql( '''update `tab{doctype}` set `{fieldname}`=repeat("*", char_length(`{fieldname}`))''' .format(doctype=doctype, fieldname=df.fieldname)) frappe.db.commit() frappe.db.sql_ddl('''drop table `__OldAuth`''')
def execute(): if '__OldAuth' not in frappe.db.get_tables(): frappe.db.sql_ddl('''alter table `__Auth` rename `__OldAuth`''') create_auth_table() # user passwords frappe.db.sql('''insert ignore into `__Auth` (doctype, name, fieldname, `password`) (select 'User', user, 'password', `password` from `__OldAuth`)''') frappe.db.commit() # other password fields for doctype in frappe.db.sql_list('''select distinct parent from `tabDocField` where fieldtype="Password" and parent != "User"'''): frappe.reload_doctype(doctype) meta = frappe.get_meta(doctype) for df in meta.get('fields', {'fieldtype': 'Password'}): if meta.issingle: password = frappe.db.get_value(doctype, doctype, df.fieldname) if password: set_encrypted_password(doctype, doctype, password, fieldname=df.fieldname) frappe.db.set_value(doctype, doctype, df.fieldname, '*'*len(password)) else: for d in frappe.db.sql('''select name, `{fieldname}` from `tab{doctype}` where `{fieldname}` is not null'''.format(fieldname=df.fieldname, doctype=doctype), as_dict=True): set_encrypted_password(doctype, d.name, d.get(df.fieldname), fieldname=df.fieldname) frappe.db.sql('''update `tab{doctype}` set `{fieldname}`=repeat("*", char_length(`{fieldname}`))''' .format(doctype=doctype, fieldname=df.fieldname)) frappe.db.commit() frappe.db.sql_ddl('''drop table `__OldAuth`''')