Skip to content
Advertisement

Tag: python

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.

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 …

Advertisement