Gudu SQLFlow Product Docs
  • 1. Introduction
    • What is Gudu SQLFlow?
      • What SQLFlow can do
      • Architecture Overview
    • Getting Started
      • Sign up a new account
        • Team Management
        • Delete My Account
        • Activate by entering a coupon
      • How to use SQLFlow
      • Different modes in Gudu SQLFlow
        • Query mode
        • Job mode
      • Basic Usage
      • Convert SQL to E-R Diagram
      • Colors in SQLFlow Diagram
      • Show call relationship
    • Installation
      • Version and Users
        • Cloud and On-Premise version
        • SQLFlow before Version 6
          • For older version SQLFlow under Linux
          • For older version SQLFlow under MacOS
          • For older version SQLFlow under Windows
      • Linux
      • MacOS
      • Windows
      • Docker
      • Clickhouse Installation
        • Clickhouse For CentOs
        • Clickhouse For Ubuntu/Debian/RHEL
      • Troubleshooting
      • Upgrade
      • Third Party Components
      • Renew License File
    • UI
      • SQLText Editor
      • Schema Explorer
      • Diagram Panel
      • Settings
      • Job Management
        • Job Sources
    • Dlineage Tool
      • Overview
      • Usage
        • Analyze data linege from SQL files
        • Analyze data linege from a database
        • Resolve the ambiguous columns in SQL query
        • Map the DataFlowAnalyzer and the settings on SQLFlow UI
        • Settings
      • Dataflow.xml structure
      • FAQ
  • 2. CONCEPTS
    • Data Lineage Basics
      • Dataflow
        • Relations generated by SQLFlow
      • Direct Dataflow
      • Indirect Dataflow
      • Aggregate function and Dataflow
      • Dataflow chain
    • Data Lineage Format Reference
  • 3. API Docs
    • Prerequisites
    • Using the Rest API
    • SQLFlow Rest API reference
      • User Interface
      • Generation Interface
        • /sqlflow
        • /sqlflow/selectedgraph/table_level_lineage
        • /sqlflow/selectedgraph/image
        • /sqlflow/graph
        • /sqlflow/graph/table_level_lineage
        • /sqlflow/graph/image
        • /sqlflow/downstreamGraph
        • /sqlflow/upstreamGraph
        • /sqlflow/erdiagramSelectGraph
        • /sqlflow/leftMostSourceTableGraph
      • Job Interface
        • /submitUserJob
        • /displayUserJobSummary
        • /displayUserJobsSummary
        • /exportLineageAsJson
        • /exportFullLineageAsJson
        • /exportLineageAsGraphml
        • /submitPersistJob
        • /displayUserLatestJobTableLevelLineage
      • Export Image
      • Export CSV
        • /sqlflow/exportFullLineageAsCsv
        • /job/exportFullLineageAsCsv
    • Swagger UI
    • Export the data lineage result
    • Python
      • Basic Usage
      • Advanced Usage
    • SQL Parser API
      • checkSyntax
  • 4. SQLFlow Widget
    • Widget Get started
    • Usages
    • Widget API Reference
  • 5. Databases
    • Database Objects
      • Azure
      • DB2
  • 6. SQLFlow-ingester
    • Introduction
      • SQLFlow-Exporter
      • SQLFlow-Extractor
      • SQLFlow-Submitter
    • Get Started
      • SQL Server
    • SQLFlow-Ingester Java API Usage
    • Understand the format of exported data
      • Oracle
      • Microsoft SQL Server
      • MySQL
      • PostgreSQL
    • List of Supported dbVendors
    • Git Repo
    • Third Party Components
  • 7. Reference
    • Lineage Model
      • Json Format Lineage Model
      • XML Format Lineage Model
      • Data Lineage Elements
    • Database Model
  • 8. other
    • FAQ
      • Handling Internal Database
      • Delete Your Account
      • Table Form Data Without Intermediates
      • Not all schema exported from Oracle
      • Lineage Customization
    • Roadmap
    • SQL Samples
      • Exchange table partition
      • Generate relationship for renamed table
      • Snowflake table function lineage detection
    • Change Logs
    • SQLFlow with Oracle XML functions
    • Major Organizations Utilizing SQLFlow
Powered by GitBook
On this page
  1. 3. API Docs
  2. Python

Basic Usage

https://github.com/sqlparser/sqlflow_public/blob/master/api/python/basic/readme.md

PreviousPythonNextAdvanced Usage

Last updated 11 months ago

A basic tutorial for using the Python version of the SQLFlow API.

Here is an advanced version of how to use.

Prerequisites

  • Python 2.7 or higher version must be installed and configured correctly.

  • Installing Dependency Libraries:

pip install requests

GenerateTokenDemo.py

This demo shows how to get a token from a SQLFlow system that can be used to legally call other interfaces.

  • Parameters:

    • userId: the user id of sqlflow web or client, required true

    • userSecret: the userSecret of sqlflow client request. sqlflow web, required false, sqlflow client, required true

This is the user id that is used to connect to the SQLFlow server. Always set this value to gudu|0123456789 and keep userSecret empty if you use the SQLFlow on-premise version.

If you want to connect to , you may to get the necessary userId and secret code.

set the parameters in the code

Connect to the SQLFlow Cloud Server:

    url = 'https://api.gudusoft.com/gspLive_backend/user/generateToken'
    userId = 'YOUR USER ID'
    screctKey = 'YOUR SECRET KEY'

Connect to the SQLFlow on-premise version:

    url = 'http://127.0.0.1:8081/gspLive_backend/user/generateToken'
    userId = 'gudu|012345678'
    screctKey = ''

start script

python GenerateTokenDemo.py

GenerateDataLineageDemo.py

This demo shows how to get the desired SQL script analysis results from the SQLFlow system.

  • Parameters:

    • userId: the user id of sqlflow web or client, required true

    • userSecret: the userSecret of sqlflow client request. sqlflow web, required false, sqlflow client, required true

    • sqltext: sql text, required false

    • sqlfile: sql file, required false

    • dbvendor: database vendor, required true, available values:

      • dbvbigquery, dbvcouchbase,dbvdb2,dbvgreenplum,dbvhana,dbvhive,dbvimpala,dbvinformix,dbvmdx,dbvmysql,dbvnetezza,dbvopenedge,dbvoracle,dbvpostgresql,dbvredshift,dbvsnowflake,dbvmssql,dbvsybase,dbvteradata,dbvvertica

    • filePath: data lineage file path

set the parameters in the code

Connect to the SQLFlow Cloud Server:

    tokenUrl = 'https://api.gudusoft.com/gspLive_backend/user/generateToken'
    generateDataLineageUrl = 'https://api.gudusoft.com/gspLive_backend/sqlflow/generation/sqlflow'
    userId = 'YOUR USER ID'
    screctKey = 'YOUR SECRET KEY'
    sqlfile = 'test.sql'
    dbvendor = 'dbvoracle'
    filePath = 'datalineage'

Connect to the SQLFlow on-premise version:

    tokenUrl = 'http://127.0.0.1:8081/gspLive_backend/user/generateToken'
    generateDataLineageUrl = 'http://127.0.0.1:8081/gspLive_backend/sqlflow/generation/sqlflow'
    userId = 'gudu|012345678'
    screctKey = ''
    sqlfile = 'test.sql'
    dbvendor = 'dbvoracle'
    filePath = 'datalineage'

start script

cmd:

  • /f. the sqlfile path,required. eg: /f sql.txt

  • /o. the data lineage file type. default value is json, optional. eg: /o csv , /o json

eg:

python GenerateDataLineageDemo.py /f test.sql /o csv

Python to get the data lineage
the SQLFlow Cloud Server
request a 30 days premium account