Website β’ Demo β’ Documentation β’ Chat
Make a wild swing at converting Crystal Reports into SQL and extracting useful metadata.
Sqlize Crystal Reports runs Aidan Ryanβs RptToXml converter to convert a directory of SAP Crystal Reports into XLM files, and then makes a strong attempt at parsing that XML out into a somewhat readable and potentially runnable t-sql statement. The results are saved into a database table along with the reports:
If mutliple queries are found in the report, there will be a db entry for each query.
π· Please chip in if you see a way to make the sql more runnable or code more readable.
good luck from here π
Here are a few links to try -
We are on a 64bit Windows Machine and built the executable with the 64 drivers. If you are on a 32bit machine you might as well rebuild from the source.
Install:
Maybe the 2nd install is redundant?
This ETL uses python > 3.7. Python can be installed from https://www.python.org/downloads/
C++ build tools are needed on Windows OS.
ODBC Driver for SQL Server is required for connecting to the database.
Finally, install the python packages:
pip install pyodbc lxml sqlparse requests xmltodict
There are a few tables to create -
USE [master]
GO
CREATE DATABASE [CrystalSQL]
CONTAINMENT = NONE
GO
USE [CrystalSQL]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Reports](
[Name] [nvarchar](max) NULL,
[Reference] [nvarchar](max) NULL,
[ReportId] [nvarchar](max) NULL,
[DocumentId] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[Templates](
[ReportName] [nvarchar](max) NULL,
[Query] [text] NULL,
[Title] [nvarchar](max) NULL,
[Description] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[Attachments](
[HRX] [nvarchar](max) NULL,
[PDF] [nvarchar](max) NULL,
[CreationDate] [datetime] NULL,
[Name] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[Documents](
[Name] [nvarchar](max) NULL,
[Description] [nvarchar](max) NULL,
[FolderId] [nvarchar](max) NULL,
[Cuid] [nvarchar](max) NULL,
[DocumentId] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
CREATE TABLE [dbo].[Objects](
[Title] [nvarchar](max) NULL,
[Cuid] [nvarchar](max) NULL,
[StatusType] [nvarchar](max) NULL,
[Type] [nvarchar](max) NULL,
[LastRun] [nvarchar](max) NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
Donβt forget to add a user account that can delete and insert.
(or, pass the variables as environment variables)
CRYSTALDATABASE = 'DRIVER={ODBC Driver 17 for SQL Server};SERVER=server_name;DATABASE=database_name;UID=username;PWD=password'
# get report sql settings
RPTSRC = '\\\\server\\Input'
# get report data settings
SAPAPIUSERNAME = "BOE_REPORT"
SAPAPIPASSWORD = "password"
SAPAPIURL = "http://server.example.net"
# get report files
CRYSTALBOEOUTPUT = "\\\\server\\Output"
There are three parts to this ETL that can be run separately.
python get_report_data.py # loads BOE report links
python get_sql.py # gets report sql code
python get_report_files.py # gets report output links. passed to Atlas as run links
Special thanks to Aidan Ryan for creating the RptToXml converter.