由买买提看人间百态

topics

全部话题 - 话题: pyodbc
1 (共1页)
l******9
发帖数: 579
1
【 以下文字转载自 Quant 讨论区 】
发信人: light009 (light009), 信区: Quant
标 题: error run SQL query from pyodbc python 3.2.5
发信站: BBS 未名空间站 (Thu Jun 19 12:04:26 2014, 美东)
I am working on pyodbc in Eclipse (4.3.2v20140221-1852) with PyDev on Win 7.
My python is 3.2.5.
At my code:
cursor.execute("select top " + str(1) + " a.my_id, a.mycode" +
"from my_table as a where a.mycode = ?", aGivenCode)
I got an error :
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server
Driver]
[SQL Ser... 阅读全帖
l******9
发帖数: 579
2
【 以下文字转载自 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_t... 阅读全帖
l******9
发帖数: 579
3
【 以下文字转载自 Quant 讨论区 】
发信人: light009 (light009), 信区: Quant
标 题: error run SQL query from pyodbc python 3.2.5
发信站: BBS 未名空间站 (Thu Jun 19 12:04:26 2014, 美东)
I am working on pyodbc in Eclipse (4.3.2v20140221-1852) with PyDev on Win 7.
My python is 3.2.5.
At my code:
cursor.execute("select top " + str(1) + " a.my_id, a.mycode" +
"from my_table as a where a.mycode = ?", aGivenCode)
I got an error :
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server
Driver]
[SQL Ser... 阅读全帖
l******9
发帖数: 579
4
【 以下文字转载自 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_t... 阅读全帖
l******9
发帖数: 579
5
【 以下文字转载自 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_t... 阅读全帖
l******9
发帖数: 579
6
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: access two databases in one ODBC connection from pyodbc
发信站: BBS 未名空间站 (Sun Aug 3 09:28:06 2014, 美东)
how to access two databases in one ODBC connection from pyodbc ?
thanks !
l******9
发帖数: 579
7
I am working on pyodbc in Eclipse (4.3.2v20140221-1852) with PyDev on Win 7.
My python is 3.2.5.
At my code:
cursor.execute("select top " + str(1) + " a.my_id, a.mycode" +
"from my_table as a where a.mycode = ?", aGivenCode)
I got an error :
pyodbc.ProgrammingError: ('42000', "[42000] [Microsoft][ODBC SQL Server
Driver]
[SQL Server]Incorrect syntax near the keyword 'as'. (156) (SQLExecDirectW)")
Why I got error at " as a " ?
thanks !
l******9
发帖数: 579
8
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_stra... 阅读全帖
l******9
发帖数: 579
9
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: access two databases in one ODBC connection from pyodbc
发信站: BBS 未名空间站 (Sun Aug 3 09:28:06 2014, 美东)
how to access two databases in one ODBC connection from pyodbc ?
thanks !
l******9
发帖数: 579
10
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: access two databases in one ODBC connection from pyodbc
发信站: BBS 未名空间站 (Sun Aug 3 09:28:06 2014, 美东)
how to access two databases in one ODBC connection from pyodbc ?
thanks !
l******9
发帖数: 579
11
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: access two databases in one ODBC connection from pyodbc
发信站: BBS 未名空间站 (Sun Aug 3 09:28:06 2014, 美东)
how to access two databases in one ODBC connection from pyodbc ?
thanks !
l******9
发帖数: 579
12
how to access two databases in one ODBC connection from pyodbc ?
thanks !
c*******h
发帖数: 107
13
俺有个6G的table(存成CSV文件大概有4G)放在SQL server上,试着用pyodbc把它读到
python里,用得就是简单的"select * from table",可是运行过程中内存消耗很快就过
了20G,这是咋会事啊?
l******n
发帖数: 9344
e*n
发帖数: 1511
15
【 以下文字转载自 Stock 讨论区 】
发信人: mitbbs2020 (bbc), 信区: Stock
标 题: Re: 【Stragety论坛】Trading with correlations.
发信站: BBS 未名空间站 (Sun Jul 25 19:52:04 2010, 美东)
用option当然可以,但不是必须,
用option可以得到更高的leverage,
但是缺点是散户量小,不容易实现market neutral。
比如1.37的hedge ratio,你要long 137和short 100个才能实现。
13和10就不那么好,而且不容易adjust,看附图就知道不怎么neutral的情况。
说stock不便于对冲,这点我不懂你什么意思。
这本身就是market neutral的strategy。
我测试过DISCA和AXP(paper account),追踪了至少2个月,涨跌幅从来没超过3%的,
但是这反过来说明这不是一对好的pair。
别的pair,没有任何leverage,一年可以做到100%以上的也有,如果我实际做stock到
这个%,
已经很满意了... 阅读全帖
l******9
发帖数: 579
16
I need to check the returned value from a stored procedure on SQL server
2008 R2.
import pyodbc
sql_str = """
DECLARE @return_value int
SET @return_value = -1
INSERT INTO [my_database].[dbo].[my_table]
EXEC @return_value = [my_database].[dbo].[my_stored_
procedure]
if @return_value <> 0
BEGIN
EXEC sys.sp_addmessage 60000, 16, ' test sp returns
wrong code ! '
... 阅读全帖
l******9
发帖数: 579
17
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: get value returned by SQLstored procedure from python
发信站: BBS 未名空间站 (Fri Aug 1 18:07:59 2014, 美东)
I need to check the returned value from a stored procedure on SQL server
2008 R2.
import pyodbc
sql_str = """
DECLARE @return_value int
SET @return_value = -1
INSERT INTO [my_database].[dbo].[my_table]
EXEC @return_value = [my_database].[dbo].[my_stored_
proce... 阅读全帖
l******9
发帖数: 579
18
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: get value returned by SQLstored procedure from python
发信站: BBS 未名空间站 (Fri Aug 1 18:07:59 2014, 美东)
I need to check the returned value from a stored procedure on SQL server
2008 R2.
import pyodbc
sql_str = """
DECLARE @return_value int
SET @return_value = -1
INSERT INTO [my_database].[dbo].[my_table]
EXEC @return_value = [my_database].[dbo].[my_stored_
proce... 阅读全帖
l******9
发帖数: 579
19
【 以下文字转载自 JobHunting 讨论区 】
发信人: light009 (light009), 信区: JobHunting
标 题: get value returned by SQLstored procedure from python
发信站: BBS 未名空间站 (Fri Aug 1 18:07:59 2014, 美东)
I need to check the returned value from a stored procedure on SQL server
2008 R2.
import pyodbc
sql_str = """
DECLARE @return_value int
SET @return_value = -1
INSERT INTO [my_database].[dbo].[my_table]
EXEC @return_value = [my_database].[dbo].[my_stored_
proce... 阅读全帖
a*****e
发帖数: 1717
20
Here's python one I used before,
drawbacks:
1. data pacing violation, limit on size of each quote, interval etc.
2. futures symbols are less standardized
3. IB data sucks, but ok for median to long term backtest
4. the ibpy is out-dated, you have to update yourself to get new
features.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from ib.ext.Contract import Contract
from ib.opt import ibConnection, message
from time import sleep
from datetime import date
import pyodbc, os, sys
# print all mess... 阅读全帖
g*******7
发帖数: 269
21
不一定就错在As,我猜是你的那几个代入的变量有问题,你最好看看真正执行的SQL就什
么样子,或者贴出来。

7.
l******9
发帖数: 579
22
来自主题: JobHunting版 - run SQL stored procedure from python (转载)
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: run SQL stored procedure from python
发信站: BBS 未名空间站 (Sat Aug 2 20:53:01 2014, 美东)
I need to run a SQL server 2008 R2 stored procedure from Eclipse pydev with
python 3.2 on win 7. If I run the stored procedure from management studio,
it works well.
But, if I run it from ptython , it does not work.
sql_str_test = """
DELETE FROM [my_db].[dbo].[my_table] -- this line works
EXEC [my_db].[dbo].[m... 阅读全帖
r**********d
发帖数: 510
23
Space between code and from? General tip for debugging query is print out
the query that you asks the to run and run it in DBS. That fixes a lot of
errors for me
o**a
发帖数: 1315
24
检查connectionstring
o**a
发帖数: 1315
25
connection string没问题的话
检查你的sql string, 比如
sql_stra1b = " value float NULL, n"
逗号是不是要去掉
再就是最好给connection加上autocommit = True
l******9
发帖数: 579
26
来自主题: Database版 - run SQL stored procedure from python
I need to run a SQL server 2008 R2 stored procedure from Eclipse pydev with
python 3.2 on win 7. If I run the stored procedure from management studio,
it works well.
But, if I run it from ptython , it does not work.
sql_str_test = """
DELETE FROM [my_db].[dbo].[my_table] -- this line works
EXEC [my_db].[dbo].[my_store_procedure] -- but this line
does not work, no run-time error message, but no results generated
"""
sql_str_connect = "DRIVER={S... 阅读全帖
l******9
发帖数: 579
27
来自主题: Database版 - run SQL stored procedure from python
Why the expected results cannot be seen ?
Also, how to access two databases in one ODBC connection from pyodbc ?
thanks !
c*******y
发帖数: 1630
28
来自主题: Quant版 - python 在windows下连接数据库
用过pyodbc,几个G的table没有出过问题。
k*****n
发帖数: 117
29
try remvoing 'as':
cursor.execute("select top " + str(1) + " a.my_id, a.mycode" +
"from my_table a where a.mycode = ?", aGivenCode)
l******9
发帖数: 579
30
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: run SQL stored procedure from python
发信站: BBS 未名空间站 (Sat Aug 2 20:53:01 2014, 美东)
I need to run a SQL server 2008 R2 stored procedure from Eclipse pydev with
python 3.2 on win 7. If I run the stored procedure from management studio,
it works well.
But, if I run it from ptython , it does not work.
sql_str_test = """
DELETE FROM [my_db].[dbo].[my_table] -- this line works
EXEC [my_db].[dbo].[m... 阅读全帖
c*******h
发帖数: 107
l******9
发帖数: 579
32
【 以下文字转载自 Database 讨论区 】
发信人: light009 (light009), 信区: Database
标 题: run SQL stored procedure from python
发信站: BBS 未名空间站 (Sat Aug 2 20:53:01 2014, 美东)
I need to run a SQL server 2008 R2 stored procedure from Eclipse pydev with
python 3.2 on win 7. If I run the stored procedure from management studio,
it works well.
But, if I run it from ptython , it does not work.
sql_str_test = """
DELETE FROM [my_db].[dbo].[my_table] -- this line works
EXEC [my_db].[dbo].[m... 阅读全帖
1 (共1页)