I have a MS SQL database in the same network but in other computer. Using the SQL Server Management Studio (SSMS) Express, I can find the database and connect without problems. But when I use pyodbc to connect to the same server using: I get following error: OBS: I guess that the server string should be right, since if I
Tag: python
How to do a where exists in nested query with SQLAlchemy?
I’m trying to do a WHERE EXISTS clause in SQLAlchemy. The SQL looks like this: Is it possible to do this in SQLAlchemy without using raw SQL? I’ve tried this but it doesn’t seem to be returning the correct results: Answer Use sqlalchemy.orm.aliased() and exists():
Sparksql filtering (selecting with where clause) with multiple conditions
Hi I have the following issue: All the values that I want to filter on are literal null strings and not N/A or Null values. I tried these three options: numeric_filtered = numeric.filter(numeric[‘LOW’] != ‘null’).filter(numeric[‘HIGH’] != ‘null’).filter(numeric[‘NORMAL’] != ‘null’) numeric_filtered = numeric.filter(numeric[‘LOW’] != ‘null’ AND numeric[‘HIGH’] != ‘null’ AND numeric[‘NORMAL’] != ‘null’) sqlContext.sql(“SELECT * from numeric WHERE LOW != ‘null’
SQLAlchemy substring is in string
I am trying to query a database for records that have a string field inside an input search string. Something like this: Of course that does not work since it is not a valid SQLAlchemy statement. This seems a simple problem but I really can’t find the right column operator. I tried the in_ operator: But that of course is
Postgresql ON CONFLICT in sqlalchemy
I’ve read quite a few resources (ao. 1, 2) but I’m unable to get Postgresql’s ON CONFLICT IGNORE behaviour working in sqlalchemy. I’ve used this accepted answer as a basis, but it gives I’ve tried adding the postgresql dialect to the @compile clause, renaming my object, but it doesn’t work. I also tried to use the str(insert())+ ” ON CONFILCT
Querying MySQL database using Python
I have a table named ‘staff’, with several columns, but the two I’m interested in are ‘username’ and ‘password’. I am trying to create a prompt which asks the user for their username (and later I will do password) and checks the table in the database to see if that username exists. I am a bit clueless about how to
Why would MySQL execute return None?
I am trying to query on a local MySQL database using Python’s (3.4) MySQL module with the following code: As far as I can tell, the connection is successful, the database is composed of several rows but the query always returns the none type. What instances does the MySQL execute function return None? Answer Query executions have no return values.
Querying association table object directly
I have to query the relationships directly, since I have to display them seperatly. task_user = db.Table( ‘pimpy_task_user’, db.Column(‘task_id’, db.Integer, db.ForeignKey(‘pimpy_task.id’)), …
Why isn’t SQLAlchemy creating serial columns?
SQLAlchemy is generating, but not enabling, sequences for columns in postgresql. I suspect I may be doing something wrong in engine setup. Using an example from the SQLAlchemy tutorial (http://docs.sqlalchemy.org/en/rel_0_9/orm/tutorial.html): With this script, the following table is generated: However, a sequence was created: SQLAlchemy 0.9.1, Python 2.7.5+, Postgresql 9.3.1, Ubuntu 13.10 -Reece Answer this is because you provided it with
Formatting a variable as a string
I am trying to create a Python program that will query a URL and produce a JSON file. I need to pass an argument in the end of the URL which comes from the SQL query. I have imported the requests …