Extract table names and other information from SQL queries
Project description
PySqlParse
Find table names and other information in a SQL query
Installation
pip3 install pysqlparse
Use
Import
from pysqlparse import parser
...
get_table_names
Returns a set of all table names (without aliases) found in the SQL string.
from pysqlparse import parser
print(parser.get_table_names('''
SELECT *
FROM requests.by_account m
INNER JOIN customer_data.styles s ON m.version = s.id
LEFT JOIN profiles.users u ON m.csm = u.id
'''))
Returns:
{'request.by_account', 'customer_data.styles', 'profiles.users'}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pysqlparse-0.0.2.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for pysqlparse-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | add4843b2ddd550f006899005b3e22cca610f0ddec8fb8585738d45cf22e8b33 |
|
MD5 | 2aaaea0e6221dffb7a9dd47a1c2d8636 |
|
BLAKE2b-256 | 3a7111bd1ae39b4a04dc8ea5931bda0ff09925ead815211caa8fa1db975e418c |