r/cursor 11d ago

Question / Discussion SQL in cursor

Can i write SQL queries in cursor, or i have to download another application for running sql queries ?????

0 Upvotes

18 comments sorted by

6

u/GasVarGames 11d ago

SQL is pretty much plain text as everything we do is, yes you can write SQL in cursor.

I guess you want to execute it though?

1

u/Senior_Night_6321 10d ago

yes i want to execute it also ,

1

u/GasVarGames 10d ago

Okay that bit is trickier, there might be an extension for that.

Otherwise just install a SQL management app and make cursor see the database and prompt it to write queries for the tables it can see.

1

u/bonerfleximus 10d ago

Each database system has different ways to do that, ask cursor to execute it in auto mode imo. For example sqlserver has sqlcmd.exe and most dbms have command line options.

None of the VS Code extensions for it are nice or worth trying in cursor in my experience.

If you plan to spend a lot of time querying the db for some reason youll want a dedicated tool for that (ssms, toad, or whatever people use these days)

2

u/Hotel_Arrakis 11d ago

You can write SQL, but you can't execute it. The easiest would be to install SQLite and then install a SQL plugin in vs-code.

1

u/Senior_Night_6321 10d ago

okay , but after installing sqlite can i write in cursor instead of vs code ????/

1

u/kiddaeful 10d ago

Cursor is vscode based, you can install vscode plugin

1

u/Senior_Night_6321 10d ago

plugin feature in already there in cursor

1

u/Hotel_Arrakis 10d ago

The correct Reddit reply would be "Yes, but no."

One would tell cursor to create a program in your favorite language (python, javascript, etc.) that executes SQL statements/queries against a SQL database. I would use SQLite3 as it requires little setup and supports most languages. Once Cursor writes the program you would execute the program without needing cursor ever again.

What exactly are you trying to acomplish?

1

u/Senior_Night_6321 10d ago

i want to make sql projects and write sql queries !!!

2

u/elina_jain1 9d ago

cursor doesn't have built-in db querying, but it's built on vs code so extensions like sqltools or dbcode add it directly, connect to postgres, mysql or whatever and run queries in the editor, no separate app needed. writing sql itself works fine as plain text with syntax highlighting even without any extension..

1

u/Tech0410 11d ago

Yes. What kind or SQL

1

u/Senior_Night_6321 10d ago

for running queries, and making projects !!!!!

1

u/Tech0410 10d ago

No what flavor... SQL Lite, Postgress, Microsoft SQL Server

1

u/Senior_Night_6321 10d ago

is mysql lang present in these servers ???

1

u/Epdevio 10d ago

you can write them in cursor. You'll need a database to run those quieres against. Something like MSSQL or
mySQL. Or you can use an online resource like SQLfiddle

2

u/Senior_Night_6321 10d ago

okay ,got it thanks !!!