473,396 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Python and MS-SQL Server

Hello,

I have programmed before, but I am new to using Python. I am
currently using the ArcGIS software which uses Python as its scripting
language for automating tasks.

The current script that I am working on requires pulling in some
information from a Microsoft SQL Server.

I was wondering if anyone could suggest the best way of doing this? I
have looked at the different modules that are specific to SQL server,
but none of them seem to be active or up to date.

If not, could anyone make any suggestions? Or would it be better to
go the ODBC route? I am not talking about large amounts of data, so I
am not concerned about performance so ODBC would be fine to use as
well.

Also, being new to Python, I recently read about dictionaries and was
wondering if there was a quick way to dump a table into a dictionary?

For example, I have a customer list with a customer ID. It would be
great to have the ID as the "key" and the name as the "data" (or even
better, have a list as the data element containing all the information
about the customer).

I am sure that this could be done manually, by looping through each
record and adding it to the dictionary -- but I was just wondering if
something like this has already been done (I don't need to reinvent
the wheel here).

Thanks so much,

Hugh
Jun 27 '08 #1
2 2854
hw*****@hotmail.com wrote:
I have programmed before, but I am new to using Python. I am
currently using the ArcGIS software which uses Python as its scripting
language for automating tasks.

The current script that I am working on requires pulling in some
information from a Microsoft SQL Server.

I was wondering if anyone could suggest the best way of doing this? I
have looked at the different modules that are specific to SQL server,
but none of them seem to be active or up to date.

If not, could anyone make any suggestions? Or would it be better to
go the ODBC route? I am not talking about large amounts of data, so I
am not concerned about performance so ODBC would be fine to use as
well.
Have a look at this:

http://ramblings.timgolden.me.uk/200...hin-python-25/

It's hardly comprehensive, but it more-or-less answers
your question.
Also, being new to Python, I recently read about dictionaries and was
wondering if there was a quick way to dump a table into a dictionary?

For example, I have a customer list with a customer ID. It would be
great to have the ID as the "key" and the name as the "data" (or even
better, have a list as the data element containing all the information
about the customer).

I am sure that this could be done manually, by looping through each
record and adding it to the dictionary -- but I was just wondering if
something like this has already been done (I don't need to reinvent
the wheel here).
The key phrase you're looking for here is ORM (Object-Relational
Mapper). Again, not an exact match for what you're saying, but
unless you app remains *remarkably* simple, you're going to end
up reinventing an ORM anyway. Probably the front runner these
days is sqlalchemy (which certainly supports MS-SQL):

http://sqlalchemy.org

but just Google for "python orm" for any number of discussions
and comparisons.

TJG
Jun 27 '08 #2
On Jun 23, 2008, at 11:10 AM, hw*****@hotmail.com wrote:
The current script that I am working on requires pulling in some
information from a Microsoft SQL Server.

I was wondering if anyone could suggest the best way of doing this? I
have looked at the different modules that are specific to SQL server,
but none of them seem to be active or up to date.

Dabo may be what you need. It is a 3-tier framework for developing
desktop applications, so even if you are doing web apps, the data
access layer is fully usable by itself. We support MS SQL Server, as
well as several other database backends.

-- Ed Leafe
-- http://dabodev.com

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: rhmd | last post by:
Just found Python and I love it. What an elegant language! I would like to use it for various applications, but the mathematical calculations are way too slow (a million sines 8 seconds in Python...
4
by: Jonathan P. | last post by:
....that would be for desktop-based apps, games, 3d graphics, and multimedia. ....thanks to APIs and bindings like Pygame, PyOpenGL, PyGtk and PyGtkGLExt. A summary of a lengthy post on the...
8
by: Mike | last post by:
Hi! Im working on some research for a asset management system. We will use python as our primary platform. As a opensource programmer the obvious question is; are there any opensource systems...
1
by: Will Stuyvesant | last post by:
I never used the popen or popen2 libraries but it is my understanding that they can capture the output of console based programs. Is it also possible to send keystrokes to console base programs? ...
14
by: BOOGIEMAN | last post by:
Well that's it, how do I make Windows Application with Python ??? Is there simple way that works 100% ? How can I rework visual design done in VS 2003 to use it for my python program ?
4
by: GujuBoy | last post by:
i want to check to see if a certain program is installed on my windows box using python. how can i do that...(ie, i want to see if "word" is installed) please help
6
by: Engineer | last post by:
I'm looking for a Python interpreter written in BASIC, preferably Visual Basic, and one written in VBA would be best of all. An alternative would be a Python-2-Basic compiler. Unfortunately I...
3
by: jefishman | last post by:
I have a Python (2.3.x) interpreter running embedded in a C++ application on a host machine. I would like to run a specific package on that host machine (numpy). I have managed to compile...
53
by: Vicent Giner | last post by:
Hello. I am new to Python. It seems a very interesting language to me. Its simplicity is very attractive. However, it is usually said that Python is not a compiled but interpreted programming...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.