sql server - pyodbc - previous sql was not a query -


i above error while trying insert data table, tried set nocount on option , still have same problem,

import pyodbc p  connstr= 'driver={sql server};server=sqlexpress;database=test;trusted_connection=yes;unicode_results=false' conn = p.connect(connstr,charset='utf-16') print conn cursor = conn.cursor()  try:     result = cursor.execute("""select col1 tb2 (select 1 col1) tb1""") except exception error:     print error  each in result.fetchall():     print each     

you need execute first select [xxx] [new_tablename] [yyy] tsql statement, read newly created tb2 table.

import pyodbc p  connstr= 'driver={sql server};server=.\sqlexpress;database=test;trusted_connection=yes;unicode_results=false' conn = p.connect(connstr,charset='utf-16') print conn cursor = conn.cursor()  try:     result = cursor.execute("""select col1 tb2 (select 1 col1) tb1""") except exception error:     print error  try:     result = cursor.execute("""select col1 tb2""") except exception error:     print error  each in result.fetchall():     print each  

also, might want change instance name .\sqlexpress instead of sqlexpress.


Comments

Popular posts from this blog

java - JavaFX 2 slider labelFormatter not being used -

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -