René's URL Explorer Experiment


Title: MySQL Parameter Binding Issue with sqlc Python Plugin · Issue #90 · sqlc-dev/sqlc-gen-python · GitHub

Open Graph Title: MySQL Parameter Binding Issue with sqlc Python Plugin · Issue #90 · sqlc-dev/sqlc-gen-python

X Title: MySQL Parameter Binding Issue with sqlc Python Plugin · Issue #90 · sqlc-dev/sqlc-gen-python

Description: Getting MySQL syntax error when trying to register users - Parameter binding issue What I'm trying to do I'm building a FastAPI application with MySQL and using sqlc to generate my database repository code. Every time I try to register a...

Open Graph Description: Getting MySQL syntax error when trying to register users - Parameter binding issue What I'm trying to do I'm building a FastAPI application with MySQL and using sqlc to generate my database reposit...

X Description: Getting MySQL syntax error when trying to register users - Parameter binding issue What I'm trying to do I'm building a FastAPI application with MySQL and using sqlc to generate my database...

Opengraph URL: https://github.com/sqlc-dev/sqlc-gen-python/issues/90

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"MySQL Parameter Binding Issue with sqlc Python Plugin","articleBody":"# Getting MySQL syntax error when trying to register users - Parameter binding issue\n\n## What I'm trying to do\nI'm building a FastAPI application with MySQL and using sqlc to generate my database repository code. Every time I try to register a user through my `/register` endpoint, I get a MySQL syntax error about the `?` placeholders.\n\n## The Problem\nWhenever I call my user registration endpoint, my application crashes with this error. It seems like the generated sqlc code isn't working properly with MySQL parameter binding.\n\n## Environment\n- **sqlc version**: 1.27.0\n- **Plugin**: sqlc-gen-python_1.3.0.wasm\n- **Database**: MySQL 8.0+\n- **Python**: 3.10\n- **SQLAlchemy**: 2.x\n- **MySQL Driver**: mysql-connector-python (also tested with PyMySQL)\n\n## Configuration\n```yaml\nversion: \"2\"\nplugins:\n  - name: py\n    wasm:\n      url: https://downloads.sqlc.dev/plugin/sqlc-gen-python_1.3.0.wasm\n      sha256: fbedae96b5ecae2380a70fb5b925fd4bff58a6cfb1f3140375d098fbab7b3a3c\nsql:\n  - engine: mysql\n    schema: \"database/migrations\"\n    queries: \"database/queries\"\n    codegen:\n      - out: repository\n        plugin: py\n        options:\n          package: repository\n          emit_sync_querier: true\n          emit_async_querier: true\n```\n\n## SQL Query\n```sql\n-- name: InsertUser :execresult\nINSERT INTO users (firstname, lastname, email, password) VALUES (?, ?, ?, ?);\n```\n\n## Generated Code (Problematic)\n```python\nINSERT_USER = \"\"\"-- name: insert_user \\\\:execresult\nINSERT INTO users (firstname, lastname, email, password) VALUES (?, ?, ?, ?)\n\"\"\"\n\ndef insert_user(self, *, firstname: Any, lastname: Any, email: Any, password: Any) -\u003e sqlalchemy.engine.Result:\n    return self._conn.execute(sqlalchemy.text(INSERT_USER), {\n        \"p1\": firstname,\n        \"p2\": lastname,\n        \"p3\": email,\n        \"p4\": password,\n    })\n```\n\n## Error\n```\nmysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, ?, ?, ?)' at line 2\n\nsqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '?, ?, ?, ?)' at line 2\n[SQL: -- name: insert_user :execresult\nINSERT INTO users (firstname, lastname, email, password) VALUES (?, ?, ?, ?)\n]\n```\n\n## What I Think is Happening\nFrom my debugging, it looks like sqlc generates SQL with `?` placeholders but then the Python code tries to pass parameters as a dictionary like `{\"p1\": firstname, \"p2\": lastname}`. From what I can tell, MySQL with SQLAlchemy doesn't like this combination.\n\n## What I Expected\nI expected the generated code to just work out of the box with MySQL, like it probably does with PostgreSQL.\n\n## What I've Tried\n1. Switching from `mysql-connector-python` to `PyMySQL` - same error\n2. Looking at the generated code and trying to understand why it's not working\n3. Manually editing the generated code (but this gets overwritten when I run `sqlc generate` again)\n\n## Impact on Me\nThis is pretty frustrating because:\n- I can't use sqlc with MySQL without manually fixing the generated code every time\n- I have to either:\n  - Manually edit the generated files after every `sqlc generate` (not sustainable)\n  - Create wrapper classes to fix the parameter binding (extra work)\n  - Switch to a different tool (defeats the purpose of using sqlc)\n\n## Is this a known issue?\nI'm not sure if this is a bug or if I'm doing something wrong with my configuration. Any help would be appreciated!\n\n## Possible Solutions (from my research)\nMaybe the generated code could:\n1. Use positional parameters: `[firstname, lastname, email, password]` instead of the dictionary\n2. Or generate SQL with `:p1, :p2, :p3, :p4` instead of `?, ?, ?, ?`\n3. Or add a config option to choose the parameter style for different databases\n","author":{"url":"https://github.com/santinalbrowns","@type":"Person","name":"santinalbrowns"},"datePublished":"2025-08-14T09:05:21.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/90/sqlc-gen-python/issues/90"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:69bbd08e-0f2f-6d52-e97c-cc38261fbb1e
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA0B0:18D1D3:883D4DA:B35D5FA:696DE224
html-safe-nonce88e4589502e683e0f8b9b7d46594c57a9bda3c13318b5823e75255831931d045
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMEIwOjE4RDFEMzo4ODNENERBOkIzNUQ1RkE6Njk2REUyMjQiLCJ2aXNpdG9yX2lkIjoiODIyMjk2ODIyNDMxMTc5NjI2MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfaae57412d3d3d156a4e2fa1a94d51ad15d6cf361290f9c636fbf12e3abad67e
hovercard-subject-tagissue:3321421894
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/sqlc-dev/sqlc-gen-python/90/issue_layout
twitter:imagehttps://opengraph.githubassets.com/681d5719c567c8690e59f56aa9ac3f7eed6764f37201df67a8b83ecf3ebc8fb9/sqlc-dev/sqlc-gen-python/issues/90
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/681d5719c567c8690e59f56aa9ac3f7eed6764f37201df67a8b83ecf3ebc8fb9/sqlc-dev/sqlc-gen-python/issues/90
og:image:altGetting MySQL syntax error when trying to register users - Parameter binding issue What I'm trying to do I'm building a FastAPI application with MySQL and using sqlc to generate my database reposit...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesantinalbrowns
hostnamegithub.com
expected-hostnamegithub.com
None4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064
turbo-cache-controlno-preview
go-importgithub.com/sqlc-dev/sqlc-gen-python git https://github.com/sqlc-dev/sqlc-gen-python.git
octolytics-dimension-user_id136738596
octolytics-dimension-user_loginsqlc-dev
octolytics-dimension-repository_id548530161
octolytics-dimension-repository_nwosqlc-dev/sqlc-gen-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id548530161
octolytics-dimension-repository_network_root_nwosqlc-dev/sqlc-gen-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7e5ae23c70136152637ceee8d6faceb35596ec46
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/sqlc-dev/sqlc-gen-python/issues/90#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsqlc-dev%2Fsqlc-gen-python%2Fissues%2F90
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fsqlc-dev%2Fsqlc-gen-python%2Fissues%2F90
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=sqlc-dev%2Fsqlc-gen-python
Reloadhttps://github.com/sqlc-dev/sqlc-gen-python/issues/90
Reloadhttps://github.com/sqlc-dev/sqlc-gen-python/issues/90
Reloadhttps://github.com/sqlc-dev/sqlc-gen-python/issues/90
sqlc-dev https://github.com/sqlc-dev
sqlc-gen-pythonhttps://github.com/sqlc-dev/sqlc-gen-python
Notifications https://github.com/login?return_to=%2Fsqlc-dev%2Fsqlc-gen-python
Fork 46 https://github.com/login?return_to=%2Fsqlc-dev%2Fsqlc-gen-python
Star 304 https://github.com/login?return_to=%2Fsqlc-dev%2Fsqlc-gen-python
Code https://github.com/sqlc-dev/sqlc-gen-python
Issues 33 https://github.com/sqlc-dev/sqlc-gen-python/issues
Pull requests 13 https://github.com/sqlc-dev/sqlc-gen-python/pulls
Actions https://github.com/sqlc-dev/sqlc-gen-python/actions
Projects 0 https://github.com/sqlc-dev/sqlc-gen-python/projects
Security Uh oh! There was an error while loading. Please reload this page. https://github.com/sqlc-dev/sqlc-gen-python/security
Please reload this pagehttps://github.com/sqlc-dev/sqlc-gen-python/issues/90
Insights https://github.com/sqlc-dev/sqlc-gen-python/pulse
Code https://github.com/sqlc-dev/sqlc-gen-python
Issues https://github.com/sqlc-dev/sqlc-gen-python/issues
Pull requests https://github.com/sqlc-dev/sqlc-gen-python/pulls
Actions https://github.com/sqlc-dev/sqlc-gen-python/actions
Projects https://github.com/sqlc-dev/sqlc-gen-python/projects
Security https://github.com/sqlc-dev/sqlc-gen-python/security
Insights https://github.com/sqlc-dev/sqlc-gen-python/pulse
New issuehttps://github.com/login?return_to=https://github.com/sqlc-dev/sqlc-gen-python/issues/90
New issuehttps://github.com/login?return_to=https://github.com/sqlc-dev/sqlc-gen-python/issues/90
MySQL Parameter Binding Issue with sqlc Python Pluginhttps://github.com/sqlc-dev/sqlc-gen-python/issues/90#top
https://github.com/santinalbrowns
https://github.com/santinalbrowns
santinalbrownshttps://github.com/santinalbrowns
on Aug 14, 2025https://github.com/sqlc-dev/sqlc-gen-python/issues/90#issue-3321421894
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.