由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Quant版 - create table on SQL server from python pyodbc
相关主题
get value returned by SQLstored procedure from python (转载)SQL combine two columns from two different tables no shared (转载)
run SQL stored procedure from python (转载)set up data mining model in SQl server 2008 win 7 (转载)
error run SQL query from pyodbc python 3.2.5SQL fast search in a 10 million records table (转载)
error of access IBM Netteza database from C# in Visual Stud (转载)access two databases in one ODBC connection from pyodbc (转载)
compare two large tables SQL (转载)how to access VBA code in another Excel workbook
sort two same tables SQL but different results (转载)华尔街日报
SQL find distinct values in large table (转载)5个offer求建议
keep group of values of SQL procedure in one table (转载)[合集] 问一个很弱的C++问题
相关话题的讨论汇总
话题: sql话题: table话题: create话题: my话题: server
进入Quant版参与讨论
1 (共1页)
l******9
发帖数: 579
1
am trying to access SQL server 2008 R2 from Eclipse pydev ( python 3.2 ) on
win7 .
I need to create a table on database.
The code can be run well. But, I cannot create tables in the database. If I
print the sql string and run the query from SQL server management studio, no
problems.
import pyodbc
sql_strc = " IF OBJECT_ID('[my_db].[dbo].[my_table]') IS NOT NULL n"
sql_strc1 = " DROP TABLE [my_db].[dbo].[my_table] n"
sql_stra = " CREATE TABLE [my_db].[dbo].[my_table] n"
sql_stra1 = "(n"
sql_stra1a = " person_id INT NOT NULL PRIMARY KEY, n"
sql_stra1b = " value float NULL, n"
sql_stra1r = "); n"
sql_str_create_table = sql_strc + sql_strc1 + sql_stra + sql_stra1 + sql_
stra1a + sql_stra1b + sql_stra1r
# create table
sql_str_connect_db = "DRIVER={SQL server};SERVER={my_db};DATABASE={my_table
};UID=my_id; PWD=my_password"
cnxn = pyodbc.connect(sql_str_connect_db)
cursor = cnxn.cursor()
cursor.execute( sql_str_create_table)
Any help would be appreciated.
Thanks
1 (共1页)
进入Quant版参与讨论
相关主题
[合集] 问一个很弱的C++问题compare two large tables SQL (转载)
[合集] 这道C语言问题如何解答?sort two same tables SQL but different results (转载)
问个简单的C++问题SQL find distinct values in large table (转载)
请教个C++的面世题keep group of values of SQL procedure in one table (转载)
get value returned by SQLstored procedure from python (转载)SQL combine two columns from two different tables no shared (转载)
run SQL stored procedure from python (转载)set up data mining model in SQl server 2008 win 7 (转载)
error run SQL query from pyodbc python 3.2.5SQL fast search in a 10 million records table (转载)
error of access IBM Netteza database from C# in Visual Stud (转载)access two databases in one ODBC connection from pyodbc (转载)
相关话题的讨论汇总
话题: sql话题: table话题: create话题: my话题: server