Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9189309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:12:30+00:00 2026-06-17T20:12:30+00:00

We need a SQL parsing or decomposing library for Python. We would like to

  • 0

We need a SQL parsing or decomposing library for Python. We would like to be able to input a SQL text query and then get the query parts back as a result. It doesn’t need to be fancy, or anything, but we would like to avoid doing the parsing ourselves. Ideally, we could do something like:

the_query = "select something from some_table where blah = 'thing' limit 15"
query_parts = the_library.parse(the_query)
print query_parts.limit().val()

>>> '15'

And this, too:

the_query = "select something from some_table where blah = 'thing'"
query_parts = the_library.parse(the_query)
print query_parts.limit().val()

>>> None

Can anyone give us any pointers for this? If the functionality is more limited, that’s OK as well.

Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T20:12:31+00:00Added an answer on June 17, 2026 at 8:12 pm

    You might like to take a look at sqlparse

    Blatantly stolen from their homepage:

    >>> # Parsing
    >>> res = sqlparse.parse('select * from "someschema"."mytable" where id = 1')
    >>> res
    <<< (<Statement 'select...' at 0x9ad08ec>,)
    >>> stmt = res[0]
    >>> stmt.to_unicode()  # converting it back to unicode
    <<< u'select * from "someschema"."mytable" where id = 1'
    >>> # This is how the internal representation looks like:
    >>> stmt.tokens
    <<<
    (<DML 'select' at 0x9b63c34>,
     <Whitespace ' ' at 0x9b63e8c>,
     <Operator '*' at 0x9b63e64>,
     <Whitespace ' ' at 0x9b63c5c>,
     <Keyword 'from' at 0x9b63c84>,
     <Whitespace ' ' at 0x9b63cd4>,
     <Identifier '"somes...' at 0x9b5c62c>,
     <Whitespace ' ' at 0x9b63f04>,
     <Where 'where ...' at 0x9b5caac>)
    >>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I`m parsing SQL query with C# Regex. I need also to make my pattern
I work on AI chat bot. I need sql query to select a single
I need a SQL query to make all data in a column UPPER CASE?
I need an sql query to give me the following: All the values in
I need execute an SQL query in ORACLE it takes a certain amount of
I'm somewhat new to SQL and need help with query syntax. My issue involves
I am parsing through HTML using Linq-to-sql. Right now to get a specific paragraph
I have 150+ SQL queries in separate text files that I need to analyze
I've got text file which I need to parse and save to SQL Server
I'm currently working with parsing some data from SQL Server and I'm in need

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.