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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:47:09+00:00 2026-06-17T22:47:09+00:00

I try execute T-SQL query in two cases (i use Win7, python 3.2, MS

  • 0

I try execute T-SQL query in two cases (i use Win7, python 3.2, MS SQL Server express 2008,pyodbc for python 3.2):

-case 1:

using MS SQL Server Management Studio i try to execute query:

USE master;CREATE DATABASE Sales ON (NAME = Sales_dat,FILENAME = 'C:\saledat.mdf',        SIZE = 10,    MAXSIZE = 50,    FILEGROWTH = 5 ) LOG ON ( NAME = Sales_log,    FILENAME = 'C:\salelog.ldf',    SIZE = 5MB,    MAXSIZE = 25MB, FILEGROWTH = 5MB );

it return successful result

-case 2:

import pyodbc
cxnn=pyodbc.connect('DSN=SERVER;UID=sa;PWD=password')
cur=cxnn.cursor()
cur.execute("USE master;CREATE DATABASE Sales ON (NAME = Sales_dat,FILENAME = 'C:\saledat.mdf',    SIZE = 10,    MAXSIZE = 50,    FILEGROWTH = 5 ) LOG ON ( NAME = Sales_log,    FILENAME = 'C:\salelog.ldf',    SIZE = 5MB,    MAXSIZE = 25MB, FILEGROWTH = 5MB );")
cxnn.commit()

but after running code i receive error

 pyodbc.Error: ('HY000', 'The driver did not supply an error!')

If i run the code without

cxnn.commit()

i have receive no error. But why?

  • 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-17T22:47:10+00:00Added an answer on June 17, 2026 at 10:47 pm

    For reasons I don’t quite understand, setting autocommit to be true seems to fix the issue. Please note that escaping the backslashes is still required.

    Autocommit can be set in two ways:

    cxnn=pyodbc.connect('DSN=SERVER;UID=sa;PWD=password', autocommit=True)
    

    Or:

    cxnn=pyodbc.connect('DSN=SERVER;UID=sa;PWD=password')
    cxnn.autocommit = True
    

    Once that’s done, creating the cursor and executing the query should then run as expected:

    cur=cxnn.cursor()
    cur.execute("USE master;CREATE DATABASE Sales ON (NAME=Sales_dat, FILENAME='C:\\saledat.mdf', SIZE=10, MAXSIZE=50, FILEGROWTH=5) LOG ON (NAME=Sales_log, FILENAME='C:\\salelog.ldf', SIZE=5MB, MAXSIZE=25MB, FILEGROWTH=5MB );")
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to execute the following SQL query using MS SQL Server Management
We are using Invoke-sqlcmd cmdlet to execute SQL query using powershell. If SQl server
I'm using groovy.sql.Sql to execute a query against Oracle and return a ResultSet that
I have a very simple sql query and when i try to execute, i
I've written a query in SQL Server 2008. The query takes about 4 minutes
I'm currently using C# to try and execute queries on a SQL database. The
I try to execute SQL select query given below. Tarih is a datetime field.
I try to execute a simple SQL query in a shell script but I
When I try to execute this statement in Oracle SQL Developer 2.1 a dialog
When I try to execute the below class using ICriteria, if (_userGroupId > 0

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.