What is the best way to connect to a Sybase database from Python?

2024/9/20 13:43:49

I am trying to retrieve data in a Sybase data base from Python and I was wondering which would be the best way to do it. I found this module but may be you have some other suggestions: http://python-sybase.sourceforge.net/ Thanks

Answer

The sybase module you linked is by far the easiest way. You can get data like so:

import Sybasedb = Sybase.connect('server','name','pass','database')
c = db.cursor()
c.execute("sql statement")
list1 = c.fetchall()print list1

You will have to use something like freetds to setup the interfaces for sybase, however.

https://en.xdnf.cn/q/72495.html

Related Q&A

How to get N random integer numbers whose sum is equal to M

I want to make a list of N random INTEGER numbers whose sum is equal to M number.I have used numpy and dirichlet function in Python, but this generate double random number array, I would like to genera…

Why sqlalchemy declarative base object has no attribute query?

I created declarative table. from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, String from sqlalchemy.dialects.postgresql import UUID import uuidBase = declarative_…

Django ModelForm not saving data

Ive tried solutions from the following posts: Saving data from ModelForm : Didnt workModelForm data not saving django : Didnt work. Im trying to save data from a ModelForm into the model. models.py:cla…

When is it appropriate to use sample_weights in keras?

According to this question, I learnt that class_weight in keras is applying a weighted loss during training, and sample_weight is doing something sample-wise if I dont have equal confidence in all the …

Django South - turning a null=True field into a null=False field

My question is, what is the best practice for turning a null=True field into a null=False field using Django South. Specifically, Im working with a ForeignKey.

Apostrophes are printing out as \x80\x99

import requests from bs4 import BeautifulSoup import resource_url = requests.get(http://www.nytimes.com/pages/business/index.html) div_classes = {class :[ledeStory , story]} title_tags = [h2,h3,h4,h5,h…

Have Sphinx replace docstring text

I am documenting code in Sphinx that resembles this: class ParentClass(object):def __init__(self):passdef generic_fun(self):"""Call this function using /run/ParentClass/generic_fun()&quo…

exit is not a keyword in Python, but no error occurs while using it

I learn that exit is not a keyword in Python by,import keyword print(exit in keyword.kwlist) # Output: FalseBut there is no reminder of NameError: name exit is not defined while using it. The outpu…

Tensorflow Datasets Reshape Images

I want to build a data pipeline using tensorflow dataset. Because each data has different shapes, I cant build a data pipeline.import tensorflow_datasets as tfds import tensorflow as tfdataset_builder …

Why is the python client not receiving SSE events?

I am have a python client listening to SSE events from a server with node.js APIThe flow is I sent an event to the node.js API through call_notification.py and run seevents.py in loop using run.sh(see …