由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - create table on SQL server from python pyodbc (转载)
相关主题
get value returned by SQLstored procedure from python两个店面题
run SQL stored procedure from python (转载)问个SQL
pypyodbc error access netezza SQL server on win7 (转载)Linkedin电面的一道SQL题
SQL multiply all values of a column in table (转载)SQL面题
compare two large tables SQLSQL某startup面经,顺便求指点
error run SQL query from pyodbc python 3.2.5 (转载)请教个SQL的问题
SQL combine two columns from two different tables no shared columnsSQL query 求解!
SQL query 求解!这题怎么做
相关话题的讨论汇总
话题: sql话题: table话题: create话题: my话题: server
进入JobHunting版参与讨论
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Quant 讨论区 】
发信人: light009 (light009), 信区: Quant
标 题: create table on SQL server from python pyodbc
发信站: BBS 未名空间站 (Fri Aug 1 13:19:15 2014, 美东)
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页)
进入JobHunting版参与讨论
相关主题
这题怎么做compare two large tables SQL
求教一个SQL的问题error run SQL query from pyodbc python 3.2.5 (转载)
sort two same tables SQL but different results (转载)SQL combine two columns from two different tables no shared columns
SQL find distinct values in large table (转载)SQL query 求解!
get value returned by SQLstored procedure from python两个店面题
run SQL stored procedure from python (转载)问个SQL
pypyodbc error access netezza SQL server on win7 (转载)Linkedin电面的一道SQL题
SQL multiply all values of a column in table (转载)SQL面题
相关话题的讨论汇总
话题: sql话题: table话题: create话题: my话题: server