Maybe because you're trying something that doesn't exist In normal bconsole if you try command ".sql" you will also have *.sql Automatically selected Catalog: mycatalog Using Catalog "mycatalog" *query keyword not found.* You have messages.
which is not "sql" command Not all traditional command have their api2 counter part, you will have to run normal command and play with return. something inspired from https://github.com/bareos/bareos/blob/master/python-bareos/bin/bconsole.py and not from https://github.com/bareos/bareos/blob/master/python-bareos/bin/bconsole-json.py Hope this help. On Tuesday 9 July 2024 at 18:45:11 UTC+2 Yan Silva wrote: > Even root access i execute and get the same error: > > [image: Screenshot_20240708_095358.png] > > Im using this bareos version: bareos-dir Version: 23.0.3~pre34.9a6c163ce > (13 March 2024) and Python 3.9. > > The same code works fine with bareos version 20.0.1 and Python 2.7 > [image: Screenshot_20240708_100429.png] > Em quarta-feira, 5 de junho de 2024 às 06:08:09 UTC-3, Jörg Steffens > escreveu: > >> Hi, >> >> I guess, you are using other credentials in Python than in the bconsole. >> The bconsole has normally root access, while in Python you are typically >> using a named console with limited permissions (profile). >> >> Regards, >> Jörg >> >> On 31.05.24 at 18:39 wrote Yan Silva: >> > Hi folks!! >> > >> > I have a script in python to get a number of jobs in Warning and Error, >> > but when i try to execute the script, for example: python >> > testing_script.py get_error_jobs, hes show me this error: >> > >> > File >> > "/usr/lib/python3.9/site-packages/bareos/bsock/directorconsolejson.py", >> > line 93, in call >> > raise bareos.exceptions.JsonRpcErrorReceivedException(json) >> > bareos.exceptions.JsonRpcErrorReceivedException: failed: .sql: is an >> > invalid command. >> > >> > The function from script is: >> > >> > def get_error_jobs(args): >> > console = create_console() >> > error_jobs = console.call('.sql query="SELECT COUNT(Job) FROM Job >> > where jobstatus=\'E\' AND starttime >= current_date - INTERVAL \'1 >> > days\';"') >> > try: >> > print((error_jobs["query"][0]["count"])) >> > except KeyError: >> > print(0) >> > >> > I execute directly this comand (.sql query="SELECT COUNT(Job) FROM Job >> > where jobstatus=\'E\' AND starttime >= current_date - INTERVAL \'1 >> > days\';) in the bconsole, and hes works fine. >> > >> > Has anyone experienced this problem? >> > >> > -- >> > You received this message because you are subscribed to the Google >> > Groups "bareos-users" group. >> > To unsubscribe from this group and stop receiving emails from it, send >> > an email to bareos-users...@googlegroups.com >> > <mailto:bareos-users...@googlegroups.com>. >> > To view this discussion on the web visit >> > >> https://groups.google.com/d/msgid/bareos-users/ca42ebd4-19b8-4de3-a855-0160ad718700n%40googlegroups.com >> >> < >> https://groups.google.com/d/msgid/bareos-users/ca42ebd4-19b8-4de3-a855-0160ad718700n%40googlegroups.com?utm_medium=email&utm_source=footer>. >> >> >> >> -- >> Jörg Steffens joerg.s...@bareos.com >> Bareos GmbH & Co. KG Phone: +49 221 630693-91 <+49%20221%2063069391> >> https://www.bareos.com >> >> Sitz der Gesellschaft: Köln | Amtsgericht Köln: HRA 29646 >> Komplementär: Bareos Verwaltungs-GmbH >> Geschäftsführer: Stephan Dühr, Jörg Steffens, Philipp Storz >> >> >> -- You received this message because you are subscribed to the Google Groups "bareos-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to bareos-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/bareos-users/a3c709b5-3387-421e-b9f2-1b98c616c5a6n%40googlegroups.com.