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 125833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T05:13:18+00:00 2026-05-11T05:13:18+00:00

I have been wondering whether there is any code out there that enables representing

  • 0

I have been wondering whether there is any code out there that enables representing SQL in the form of some object tree that can be assembled, modified and then finally rendered to valid SQL?

Off the top of my head it could look something like that…

var stmnt = new Statement(); stmnt   .AddMaster('Customer')   .Show('Firstname, 'Lastname')   .AddJoin('Address', 'ID', 'CustomerID')   .Show('Street', 'City'); stmnt.WhereStatement()   .AddParameter('Address.City', Op.Equal);  string sql = stmnt.Generate(); // select a.FirstName, a.LastName, b.Street, b.City // from Customer a // join Address b on b.CustomerID = a.ID // where b.City = :p1 

This is just an example and the thing out there may work totally different, but yes, I’d love to hear what is out tere in that respect.

UPDATE:

I am aware of the numerous possibilities of using ORM technologies to get my results from the DB, but I was after a model for the SQL itself. I know that the level of abstraction is pretty low, but it could possibly allow a situation where multiple collaborators can work on an SQL statement (multiple joins, multiple wheres) which can then be ‘rendered’ at the end of the build-Phase.

  • 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. 2026-05-11T05:13:19+00:00Added an answer on May 11, 2026 at 5:13 am

    The python package SQLAlchemy has an ORM layer, but it also has an SQL generation layer.

    [I realise you tagged this post c# and .net, but I thought you might like to see what else is out there]

    Here is some example code:

    from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from sqlalchemy.sql import select  metadata = MetaData()  # Make a basic customer table. Customer = Table('Customer',                  metadata,                  Column('ID', Integer, primary_key=True),                  Column('FirstName', String),                  Column('LastName', String))  # Make a basic address table Address = Table('Address',                 metadata,                 Column('ID', Integer, primary_key=True),                 Column('City', String),                 Column('Street', String),                 Column('CustomerID', None, ForeignKey('Customer.ID')))   # Generate some sql stmt = select([Customer.c.FirstName,                Customer.c.LastName,                Address.c.Street,                Address.c.City],               from_obj=Customer.join(Address),               whereclause=Address.c.City == 'Wellington')  # Display print stmt # output: SELECT 'Customer'.'FirstName', 'Customer'.'LastName', 'Address'.'Street', 'Address'.'City'  FROM 'Customer' JOIN 'Address' ON 'Customer'.'ID' = 'Address'.'CustomerID'  WHERE 'Address'.'City' = :City_1  # note that SQLAlchemy picked up the join condition from the foreign key. # you can specify other join conditions if you want. 

    Typically, you would execute the statement by using SQLAlchemy to connect to a database. Then you can do:

    for row in stmt.execute():     print 'Name:', row.c.FirstName, row.c.LastName, 'City:', row.c.City 

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been wondering what is better way of using code. Is there any
there is a project using nhibernate v2.1 and i have been wondering whether v3
I have been wondering if there is a way of specifying the maximum of
I have been wondering why the code below is giving me different output on
Lately i have been wondering if there is a performance difference between repeating the
I have been wondering... Do the new Async constructs actually allow for intermediate results
I have been wondering for a while what the difference is between the following
I have been wondering about the reload() function in python, which seems like it
I have been wondering about the performance of regular expression implementations lately, and have
Something I have been wondering about properties for a while. When you are using

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.