Questions tagged [sqlobject]

SQLObject is a free and open-source (LGPL) Python object-relational mapper. SQLObject supports a number of backends: MySQL/MariaDB (with a number of DB API drivers: MySQLdb, mysqlclient, mysql-connector, PyMySQL, mariadb), PostgreSQL (psycopg2, PyGreSQL), SQLite (builtin sqlite, pysqlite). Works under Python 2.7 and 3.4+.

Filter by
Sorted by
Tagged with
-1 votes
1 answer
30 views

How to get the database row id in a SQLObject Python class method to mimic AddRemoveName

When creating a table with SQLObject, it generates a primary key ID that is not in the Class definition ( ex Person and Address) This ID must be used to point to a related table ( foreign key) As far ...
Ghisbo's user avatar
  • 3
0 votes
0 answers
24 views

About flask ORM

I am a Django developer but recreantly started work with Flask. My problem is i want perform CRUD operation in flask using sqlite3. can i do this? Below i have put my ORM. how is work and how data ...
user17189097's user avatar
1 vote
1 answer
25 views

Print SQL generated by SQLObject

from sqlobject import * class Data(SQLObject): ts = TimeCol() val = FloatCol() Data.select().count() Fails with: AttributeError: No connection has been defined for this thread or process ...
davetapley's user avatar
  • 17.1k
1 vote
2 answers
157 views

Mocking sqlobject function call for test db

I am trying to mock sqlbuilder.func for test cases with pytest I successfully mocked sqlbuilder.func.TO_BASE64 with correct output but when I tried mocking sqlbuilder.func.FROM_UNIXTIME I didn't get ...
Chandan's user avatar
  • 11.5k
1 vote
1 answer
84 views

How to construct sql query with bitwise operation using sqlobject ORM in python3?

I am trying to create a query in python3 using sqlobject mapper. I have a requirement of filtering a custom field based on the output of bitise operation. Query looks like this: query = sqlobject.AND(...
Rajat Doshi's user avatar
0 votes
1 answer
62 views

How to do following sql operation using Table.select() method in python sqlobject?

Sql Operation: SELECT *, CASE WHEN quota_unit = 'MB' THEN quota*1024 ELSE quota END AS data_usage FROM mapping ORDER BY data_usage; I tried like ...
SAG786's user avatar
  • 11
2 votes
1 answer
196 views

Filter "value in list" with SQLObject ORM

I wanted to use SQLObject to allow my co-workers to get some data from my MySQL database. Now I need to use filter "value in list" but I don't know how can I do that. I choosed SQLObject because it ...
Vether's user avatar
  • 65
1 vote
2 answers
147 views

trying to add data and query a mysql database using sqlobject and python 3

My code is raising an exception as shown below. I am pretty sure the problem is with my definition of the table relationship. I have tried multiple alternatives that give varying errors :-( I have ...
jordanthompson's user avatar
1 vote
1 answer
49 views

python3 with SQLObject class pass parameters

I am new to python3 and tring to build a sqlobject class which named whatever. Then I created a function to caculate the average of one column. Here are parts of the codes. class whatever(sqlobject....
Ze  Xu's user avatar
  • 13
2 votes
1 answer
285 views

Possible to get a generator over a custom SQLObject Select call?

I'm using the SQLObject ORM in Python, and I want to be able to iterate over a generator (of the row objects) in the same way I would Table.select(...), but what I can get from doing this method call ...
Benjamin R's user avatar
2 votes
1 answer
297 views

SqlObject and SqlBuilder IN() function with string values

as my first post here, I would like to warn that I looked as well as I could on the web but nothing that solved it. I am using python 2.7 and latest version of sqlobject lib. I faced that when ...
DFE's user avatar
  • 126
2 votes
1 answer
277 views

How to call queryAll method

I was going through the instructions specified under SQL statements, and I got stuck at this line: rows = connection.queryAll(query) From where are we getting this connection object? Because I am ...
Kaushik Shrestha's user avatar
1 vote
1 answer
100 views

ConnectionURI MSSQL Python

I'm coding a little something in Python. I need to get some data from a MicrosoftSQL database and convert it to a JSONObject. And i think i have some problems with the ConnectionForURI. I'm using ...
Stains's user avatar
  • 97
2 votes
2 answers
98 views

SQLObject install without internet

Trying to setup a python flask server in a controlled environment, no access to internet # python setup.py install Traceback (most recent call last): File "setup.py", line 9, in <module> ...
tesgo's user avatar
  • 66
2 votes
1 answer
349 views

Python SQL Object selecting data by dictionary and date

I am using SQLObject, a wrapper for python to manage SQL Queries, with Python 2.7. I know I can select data by using a dictionary such as: restrictions = { ... } selection = sql_table.selectBy(**...
OmegaNalphA's user avatar
2 votes
1 answer
81 views

Update value checking previous one - SQLObject

In an application already deployed, using SQLObject, I need to update a value only if the previous value match a certain value. The equivalent sql could be: UPDATE jobs SET status='150' WHERE id=...
KumZ's user avatar
  • 565
2 votes
1 answer
68 views

How to bundle an app including SQLObject using cx_Freeze

Background I'm using cx_Freeze to build Windows and Mac packages of my application; the build executes successfully on both platforms resulting in an msi on Windows and dmg/app on Mac which I can ...
Alex's user avatar
  • 41
0 votes
1 answer
120 views

Accessing data for SQL object inner join

I am trying to get this inner join to show output the the title and date. Is only returning the sql object that gives details on object. this is result. I can access num_rows but just gives me int(11) ...
user3775749's user avatar
2 votes
2 answers
238 views

SQLObject throws: Unknown database 'dbname?charset=utf8'

I've got third-party Python script, it looks like it has to connect to MySQL database by means of SQLObject package. Considering I've provided correct DSN, the script throws sqlobject.dberrors....
Estus Flask's user avatar
1 vote
0 answers
400 views

JOIN table with array

I get a response from a JSON API which contains the following data. "data": [ { "num1": 1, "num2": 2, "txt1": "test3" }, { "num1": 4, "num2": 5, ...
Mtihc's user avatar
  • 191
0 votes
1 answer
1k views

JDBI, Model Mapper and SQL Object Queries

I'm using Model Mapper with JDBI, but I'm not able to use model mapper with SQL Object Queries. For example I have this select @SqlQuery("select * from example") and documentation says I have to ...
Silvia's user avatar
  • 11
2 votes
1 answer
200 views

How to implement callback on connection drop event using SQLObject?

I'm using a Python script that does certain flow control on our outgoing mail messages, mostly checking whether a user is sending spam. The script establishes a persistent connection with a database ...
nKn's user avatar
  • 13.7k
1 vote
1 answer
25 views

SQLObject: reusing my arguments list

I'm using SQLObject and I've got the following: # update foo if it exists, otherwise create a new one if self.foo_exists: Foo.get(foo_id).set(name = foo['name'], ip = foo['ip'], port = foo['port'], ...
stephenmurdoch's user avatar
3 votes
1 answer
252 views

sqlobject thread safety

My python script reads and increments a row attribute. I call this function from 4 different threads. def update_row(): row = myTable.select(myTable.q.id==1, forUpdate=True)[0] row....
Sachin Khot's user avatar
  • 1,412
0 votes
1 answer
1k views

CONCAT_WS in sqlalchemy?

In my sqlobject implementation I have the following line: members = Member.select("CONCAT_WS(' ', member.first_name, member.last_name, member.personal_code_number, member.mail) like " + Member....
Markus Johansson's user avatar
0 votes
2 answers
651 views

SQLobject installed but IMDbPY fail

I tried using SQLobject from IMDbPY and Python said the driver didn't work- I'm running PostgreSQL 9.2. C:\Users\dom\AppData\Roaming\Python\Scripts>python imdbpy2sql.py -d /imdb -u 'postgres://...
trianIMDB's user avatar
1 vote
1 answer
729 views

Python ORM Library that can be used without a database connection

I need to figure out how to create a class that has optional ORM functionality, ie sometimes I will need to save it to a database, and other times I will not have to (I will have no connection). ...
d0c_s4vage's user avatar
  • 3,947
13 votes
3 answers
12k views

Dynamic Order in JDBI SQL Object Queries

How do you do ordering with SQL Object Queries in JDBI? I want to do something like: @SqlQuery( "SELECT * FROM users " + "WHERE something = :something " + "ORDER BY :orderBy :orderDir" ) ...
sclausen's user avatar
  • 1,720
0 votes
1 answer
657 views

Closing an SQLObject Connection

Is it possible to manually close an SQLObject Connection once it has been opened? I am trying to delete a database file once it has been used, but it seems that the open connection to the database ...
JimmidyJoo's user avatar
  • 10.6k
1 vote
1 answer
413 views

sqlobject sqlmeta with composite key

I have created my sqlobject class like so and set the primary key to prm_id import sqlobject from connection import conn class tbl_episodes(sqlobject.SQLObject): class sqlmeta: ...
Aatish Molasi's user avatar
2 votes
3 answers
912 views

SQLObject: how to remove first N objects from the table?

I have an application that keeps track on items and uses SQLObject python ORM. At some point of time app checks if table is not too big, and if it's more than 10000 items in table it removes first N ...
grigoryvp's user avatar
  • 40.5k
2 votes
1 answer
236 views

SQLObject - Updating Many Records

I am using SQLObject with an sqlite database to store document records. The documents have been scanned the document information stored in a text file. I need to read all these text files (about 800) ...
jimscafe's user avatar
  • 1,081
1 vote
1 answer
934 views

how to do 'select in' operation in sqlobject

I want write a SQL statement like this: select * from 'table' t where t.id in (1,2,4) But I don't how to using SQLObject's grammar.
fangshi's user avatar
  • 13
1 vote
0 answers
136 views

SQLObject lazyupdate is resetting fields to default values when I read them (python 2.7, postgresql 9.1)

I'm trying to use SQLObject's lazyUpdate feature and my data is getting clobbered. Here's the class definition class T(sqlobject.SQLObject): class sqlmeta: lazyUpdate = True def ...
Vroo's user avatar
  • 1,064
6 votes
4 answers
2k views

How to install and use sqlobject+mysql on iron python?

Is it possible to use sqlobject to connect to a mysql database from iron python? If so, how? What must I install? I have sqlobject installed for cpython and it works fine, but if I use that same ...
Bryan Oakley's user avatar
1 vote
0 answers
223 views

Migrating from SQLObject to SQLAlchemy :: Can SQLAlchemy support zero caching and autoload table updates?

I want to know if SQLAlchemy can support instant loading of the current state of an object from the database when another process updates some attributes of the same object. I want to mention, I am ...
user866937's user avatar
0 votes
2 answers
378 views

Choosing Python/SQLObject webframework

I have a regular desktop application which is written in Python/GTK and SQLObject as ORM. My goal is to create a webinterface where a user can login and sync/edit the database. My application is split ...
Timo's user avatar
  • 164
1 vote
1 answer
389 views

Good idea/Best way to extend Spine.Model

[background below] I've got my data modelled out in SQLObject in Python on the back-end. Right now I'm converting an SQLObject to a dict, and grabbing all the keys from the dict and then exporting ...
tkone's user avatar
  • 22.2k
1 vote
1 answer
113 views

A more pythonic way to build a class based on a string (how not to use eval)

OK. So I've got a database where I want to store references to other Python objects (right now I'm using to store inventory information for person stores of beer recipe ingredients). Since there are ...
tkone's user avatar
  • 22.2k
1 vote
3 answers
2k views

Easier way to create a JSON object from an SQLObject

EDIT -- took the code from below and made it so it can handle ForiegnKeys, Decimal numbers (although i'm doing a very forced float conversion). It returns a dict now so it can be recursive. from ...
tkone's user avatar
  • 22.2k
0 votes
1 answer
676 views

How to manage db connections using webpy with SQLObject?

Web.py has its own database API, web.db. It's possible to use SQLObject instead, but I haven't been able to find documentation describing how to do this properly. I'm especially interested in ...
automaciej's user avatar
0 votes
1 answer
282 views

ManyToMany relationships on the same table in SQLObject

My google foo has been coming up short on this, so I throw this to the geniuses here. I'm writing some beer recipe creation software and I've got a class in SQLObject and I'd like to have a ...
tkone's user avatar
  • 22.2k
3 votes
1 answer
1k views

Migrating data from one sqlite database to multiple SQLite databases using SQLObject

Till now our application has been using one SQLite database with SQLObject as the ORM. Obviously at some point we knew we had to face the SQLite concurrency problem and so we did. We ended up ...
user866937's user avatar
7 votes
3 answers
22k views

python raw string assignment

Given a file contains lines such as: (?i:\bsys\.user_catalog\b) While reading those line, I want the value to be a raw string (unescaped), meaning, in memory, line should be r'(?i:\bsys\....
Tzury Bar Yochay's user avatar
1 vote
1 answer
867 views

Error returned when running imdbpy2sql.py with MySQL database

I am working on getting IMDbPY installed and working and I have come to a point where I am working on pulling in all of the data from the flat (text) files in to a (MySQL) database. When I run the ...
Cody's user avatar
  • 11
14 votes
4 answers
21k views

How to make mysql connection that requires CA-CERT with sqlalchemy or SQLObject

I would like to connect to a MySQL database that requires ca-cert. I can do it with MySQLdb like below: MySQLdb.connect(host = self.host, port = self.port, ...
cfpete's user avatar
  • 4,143
1 vote
3 answers
554 views

web presenting framework for SQLObject/SQLAlchemy projects

I'm looking for the most graceful way of taking a non-web project based on either SQLObject or SQLAlchemy and overlay it with a decent web-framework. I've looked at Turbogears, and even though it ...
joveha's user avatar
  • 2,599
0 votes
1 answer
2k views

SQL Alchemy or SQL Object in Bottle Python

hi i am a newbie just starting off on bottle.py framework does anyone have a sample CRUD application that we can learn from? secondly which of the two wrappers runs faster in bottle?thanks.
john kesh mahugu's user avatar
0 votes
1 answer
226 views

sqlobject: leak memory using selectby method

I had discovered that using selectby method with sqlobject there are leak memory. For example, when I execute this code: connection = connectionForURI('postgresql://test:test@localhost/...
rrobles's user avatar
5 votes
2 answers
2k views

python: Why does SQLObject fail in conn.autocommit(1)?

In my server code, there is a call to _SO_fetchAlternateID (nested in some value call), which ultimately calls makeConnection in pgconnection.py. This call fails on conn.autocommit(1), with the ...
Ovesh's user avatar
  • 5,229