pyodbc

How can I change password for sql login to database using pyodbc?

假如想象 提交于 2020-01-23 17:17:05
问题 I try change password for sql login to database using pyodbc in python But I get error - Wrong syntax near object "@P1" (102) (SQLExecDirectW).....Cannot prepare the instruction (8180) config.login = 'user' config.haslo = '12345' haslo = 'abcde' con = pyodbc.connect("DRIVER={ODBC Driver 11 for SQL Server};" "SERVER=Serwer;" "DATABASE=Baza;" "UID="+config.login+";" "PWD="+config.haslo+";" "autocommit=true") kursor = con.cursor() zapytanie = """ALTER LOGIN ? with password = ? old_password = ?""

Writing python (pandas) Data Frame to SQL Database Error

帅比萌擦擦* 提交于 2020-01-23 13:33:44
问题 I am trying to put a python data frame to a MS SQL DB and I am getting the following error FUNCTION def put_to_server(df): # df is a pandas data frame server="KORNBSVM04\MSSQLSERVER2012" Driver="{SQL Server}" userid='' pswd='' cnxn = pyodbc.connect(driver=Driver, server=server, database="CIHOTLINE",uid=userid, pwd=pswd) cur=cnxn.cursor() df.to_sql(name='dbo.test',con=cnxn) ERROR File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 950, in to_sql index_label=index_label) File "C:

Writing python (pandas) Data Frame to SQL Database Error

…衆ロ難τιáo~ 提交于 2020-01-23 13:33:35
问题 I am trying to put a python data frame to a MS SQL DB and I am getting the following error FUNCTION def put_to_server(df): # df is a pandas data frame server="KORNBSVM04\MSSQLSERVER2012" Driver="{SQL Server}" userid='' pswd='' cnxn = pyodbc.connect(driver=Driver, server=server, database="CIHOTLINE",uid=userid, pwd=pswd) cur=cnxn.cursor() df.to_sql(name='dbo.test',con=cnxn) ERROR File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 950, in to_sql index_label=index_label) File "C:

Writing python (pandas) Data Frame to SQL Database Error

二次信任 提交于 2020-01-23 13:32:28
问题 I am trying to put a python data frame to a MS SQL DB and I am getting the following error FUNCTION def put_to_server(df): # df is a pandas data frame server="KORNBSVM04\MSSQLSERVER2012" Driver="{SQL Server}" userid='' pswd='' cnxn = pyodbc.connect(driver=Driver, server=server, database="CIHOTLINE",uid=userid, pwd=pswd) cur=cnxn.cursor() df.to_sql(name='dbo.test',con=cnxn) ERROR File "C:\Python27\lib\site-packages\pandas\core\generic.py", line 950, in to_sql index_label=index_label) File "C:

Client-side pyodbc error: “Server does not exist or access denied.”

僤鯓⒐⒋嵵緔 提交于 2020-01-23 12:19:41
问题 I have a python application designed to pull data from a remote database server using pyodbc, then organize and display the data in a spreadsheet. I've had it working fine for several months now, with multiple coworkers in my department using it through a shared network folder. My connection: pyodbc.connect('DRIVER={SQL Server}; SERVER=<myServer_name>; DATABASE=<myDB_name>; UID=personsUser; PWD=personsPassword') A different employee within our same network recently tried to use the program

Error “Previous SQL was not a query” in Python?

老子叫甜甜 提交于 2020-01-23 05:27:40
问题 I am trying to call a stored procedure in Python but it keeps giving me the following error. The procedure is written in SQL Server 2008 and I am using PyODBC to call the method and pass parameters to it. import pyodbc cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER='+serveripaddr+';DATABASE='+database+';UID='+userid+';PWD='+password+'') cursor = cnxn.cursor() cursor.execute("{call p_GetTransactionsStats('KENYA', '41')}") rows = cursor.fetchall() The last line results in the following

Execute SQL file with multiple statements separated by “;” using pyodbc

人走茶凉 提交于 2020-01-22 19:55:06
问题 I am currently writing a script to run multiple SQL files using Python, a little background before you mention alternative methods; this is to automate the scripts and Python is the only tools I have on our windows 2008 server. I have a script that works for one set but the issue is when the other set has two statements instead of one seperated by a ';' here is my code: import os import pyodbc print ("Connecting via ODBC") conn = pyodbc.connect('DSN=dsn', autocommit=True) print ("Connected!\n

“TypeError: 'NoneType' object is not iterable” from pandas read_sql

我怕爱的太早我们不能终老 提交于 2020-01-21 21:48:45
问题 I am trying to run a SQL command using pyodbc in python. in which SQL command contains multiple SELECT commands and IF statements. but I am getting an error as follows columns = [col_desc[0] for col_desc in cursor.description] TypeError: 'NoneType' object is not iterable import pyodbc import pandas as pd conn = pyodbc.connect("DRIVER={SQL Server};" "SERVER=server_name;" "DATABASE=master;" "Trusted_Connection=yes;") cursor = conn.cursor() script=""" If object_id ('tempdb..#Temp1')is not null

pyodbc.ProgrammingError: ('The SQL contains 0 parameter markers, but 3 parameters were supplied', 'HY000')

余生颓废 提交于 2020-01-21 08:30:12
问题 I am using Python 3.6, flask, pyodbc, and connect to SQL Server. I am trying to make a connection to a database, then creating a query with parameters. Here is the code: app.py from flask import Flask, render_template, flash, redirect, url_for, session, request, logging from wtforms import Form, StringField, TextAreaField, PasswordField, validators from passlib.hash import sha256_crypt from functools import wraps import pyodbc import os app = Flask(__name__) # Config SQL Server conn = pyodbc

to_sql pyodbc count field incorrect or syntax error

不打扰是莪最后的温柔 提交于 2020-01-19 03:27:46
问题 I am downloading Json data from an api website and using sqlalchemy, pyodbc and pandas' to_sql function to insert that data into a MSSQL server. I can download up to 10000 rows, however I have to limit the chunksize to 10 otherwise I get the following error: DBAPIError: (pyodbc.Error) ('07002', '[07002] [Microsoft][SQL Server Native Client 11.0]COUNT field incorrect or syntax error (0) (SQLExecDirectW)') [SQL: 'INSERT INTO [TEMP_producing_entity_details] There are around 500 Million rows to