SQL queries. I am poor at writing SQL queries with bunches of joins. I just show it the table definitions and tell it what I want. Sometimes it doesn't get it quite right (which is why you need some knowledge of what you are asking of it) and I point it out and it fixes it.
Regular Expressions. I hate doing regexps. It is excellent at them.
Wiki articles for an encyclopedia I'm developing. It is great at this, but occasionally I catch it hallucinating articles out of whole cloth because it has access to zero information about what I asked it about, so it just goes from the article title and imagines what it must be about.
I know where to use it right, and I've found my output has not only doubled since I started using it, I am enjoying coding even more than ever because it has got rid of the worst drudgery that would cause me to switch from my IDE to my browser and bring up HN to avoid working.
I've also been using ChatGPT to create SQL queries -- it's genuinely really, really great at this. I do have to say "I'm using PostgreSQL with DataGrip IDE" and feed it back any errors I get, because there are a lot of permutations for SQL, but it's a pretty seamless experience overall.
Here's an example of one that helped me a lot. This takes no time at all to get ChatGPT to generate by giving it anonymized snippets of table data saying:
"here's an example of the relevant tables, I want output that looks like this, what query does that?"
and it just works instantly.
ChatGPT did NOT format it this way, I changed the line breaks and indentation formatting to better fit viewing in Chrome/Safari. I also renamed tables/columns out of personal responsibility, to generic names which make it all the more confusing.
-- Existing Records
WITH search_table_A AS (
SELECT * FROM tableA
WHERE some_primary_key = :searchKey
),
search_table_B AS (
SELECT * FROM tableB
WHERE some_primary_key = :searchKey
),
combined_query AS (
SELECT COALESCE(search_table_A.our_UUID, search_table_B.our_UUID) AS our_UUID
FROM search_table_A
LEFT JOIN search_table_B ON search_table_A.some_primary_key = search_table_B.some_primary_key
)
SELECT tableC.*
FROM tableC
JOIN combined_query ON tableC.our_UUID = combined_query.our_UUID;
Thirded, my only complaint is that it helpfully strips out comments and occasionally forgets which SQL variant I’m using. I have found it helpful to feed it back my query after I’ve implemented the recommended changes and made my tweaks, along with something like, “this is what I did, can you help me improve the section starting with `SELECT * FROM product`… the context seems to improve it’s subsequent recommendations.
Maybe you're using the paid version, or I suck too much at prompting, but so far I wasn't able to rely on the generated SQL and not for lack of trying. Workable queries, yes, but never doing what I intended...
I only just got access to the Plus version. But for the last month or so I've been using the free version with absolutely no problems in the scripts it generates.
I’m curious what it saves you. I’ve done the same for a couple months, but found its results too unreliable to be of any use to me, in terms of time savings.
It's also great at fixing SQL queries that the database errors on.
So now, rather than take time to get complex queries right, I quickly sketch a query that's roughly what I want, and tell ChatGPT to "Fix this Sqlite query."
Short, functional things like this I've found to really be ChatGPT's strength. For example, I had some godawful nested PHP code that had been written years ago I was trying to muck with. Asking GPT to sort it out for me took me way less time than trying to figure it out myself.
I've also used it for SQL queries and things like list comprehension, etc.
The few times I've pasted in whole code blocks and asked it to do XYZ, I've ended up basically debugging my prompt instead of my code.
Regular Expressions. I hate doing regexps. It is excellent at them.
Wiki articles for an encyclopedia I'm developing. It is great at this, but occasionally I catch it hallucinating articles out of whole cloth because it has access to zero information about what I asked it about, so it just goes from the article title and imagines what it must be about.
I know where to use it right, and I've found my output has not only doubled since I started using it, I am enjoying coding even more than ever because it has got rid of the worst drudgery that would cause me to switch from my IDE to my browser and bring up HN to avoid working.