I'd strongly recommend you don't go any further down the path of reading the database, it's the worst possible way you can report on Jira.
This quuery is however simple and safe - read the project table - it's got the key and next number to use in it amongst other project data (note next number - not necessarily the number of issues in the project)