Question
stringlengths
25
7.47k
Q_Score
int64
0
1.24k
Users Score
int64
-10
494
Score
float64
-1
1.2
Data Science and Machine Learning
int64
0
1
is_accepted
bool
2 classes
A_Id
int64
39.3k
72.5M
Web Development
int64
0
1
ViewCount
int64
15
1.37M
Available Count
int64
1
9
System Administration and DevOps
int64
0
1
Networking and APIs
int64
0
1
Q_Id
int64
39.1k
48M
Answer
stringlengths
16
5.07k
Database and SQL
int64
1
1
GUI and Desktop Applications
int64
0
1
Python Basics and Environment
int64
0
1
Title
stringlengths
15
148
AnswerCount
int64
1
32
Tags
stringlengths
6
90
Other
int64
0
1
CreationDate
stringlengths
23
23
I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like /usr/lib/python2.5/site-packages/mypacka...
32
19
1
0
false
9,918,496
0
28,993
2
0
0
39,104
Use pkgutil.get_data. It’s the cousin of pkg_resources.resource_stream, but in the standard library, and should work with flat filesystem installs as well as zipped packages and other importers.
1
0
1
Finding a file in a Python module distribution
4
python,distutils
0
2008-09-02T09:40:00.000
I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like /usr/lib/python2.5/site-packages/mypacka...
32
3
0.148885
0
false
39,295
0
28,993
2
0
0
39,104
That's probably the way to do it, without resorting to something more advanced like using setuptools to install the files where they belong. Notice there's a problem with that approach, because on OSes with real a security framework (UNIXes, etc.) the user running your script might not have the rights to access the DB ...
1
0
1
Finding a file in a Python module distribution
4
python,distutils
0
2008-09-02T09:40:00.000
All the docs for SQLAlchemy give INSERT and UPDATE examples using the local table instance (e.g. tablename.update()... ) Doing this seems difficult with the declarative syntax, I need to reference Base.metadata.tables["tablename"] to get the table reference. Am I supposed to do this another way? Is there a different ...
8
4
0.26052
0
false
77,962
0
2,919
2
0
0
75,829
via the __table__ attribute on your declarative class
1
0
0
Best way to access table instances when using SQLAlchemy's declarative syntax
3
python,sql,sqlalchemy
0
2008-09-16T19:08:00.000
All the docs for SQLAlchemy give INSERT and UPDATE examples using the local table instance (e.g. tablename.update()... ) Doing this seems difficult with the declarative syntax, I need to reference Base.metadata.tables["tablename"] to get the table reference. Am I supposed to do this another way? Is there a different ...
8
0
0
0
false
315,406
0
2,919
2
0
0
75,829
There may be some confusion between table (the object) and tablename (the name of the table, a string). Using the table class attribute works fine for me.
1
0
0
Best way to access table instances when using SQLAlchemy's declarative syntax
3
python,sql,sqlalchemy
0
2008-09-16T19:08:00.000
I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a small subset of rows from a potentially very large table. The exact choice of what ro...
5
1
0.022219
0
false
141,872
0
2,773
6
0
0
140,026
"implement a Domain Specific Language" "nobody is going to want to install a server that downloads and executes arbitrary Python code at runtime" I want a DSL but I don't want Python to be that DSL. Okay. How will you execute this DSL? What runtime is acceptable if not Python? What if I have a C program that happens...
1
0
0
Writing a Domain Specific Language for selecting rows from a table
9
python,database,algorithm,dsl
0
2008-09-26T14:56:00.000
I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a small subset of rows from a potentially very large table. The exact choice of what ro...
5
0
0
0
false
140,066
0
2,773
6
0
0
140,026
Why not create a language that when it "compiles" it generates SQL or whatever query language your datastore requires ? You would be basically creating an abstraction over your persistence layer.
1
0
0
Writing a Domain Specific Language for selecting rows from a table
9
python,database,algorithm,dsl
0
2008-09-26T14:56:00.000
I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a small subset of rows from a potentially very large table. The exact choice of what ro...
5
0
0
0
false
140,304
0
2,773
6
0
0
140,026
It really sounds like SQL, but perhaps it's worth to try using SQLite if you want to keep it simple?
1
0
0
Writing a Domain Specific Language for selecting rows from a table
9
python,database,algorithm,dsl
0
2008-09-26T14:56:00.000
I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a small subset of rows from a potentially very large table. The exact choice of what ro...
5
0
0
0
false
140,091
0
2,773
6
0
0
140,026
You mentioned Python. Why not use Python? If someone can "type in" an expression in your DSL, they can type in Python. You'll need some rules on structure of the expression, but that's a lot easier than implementing something new.
1
0
0
Writing a Domain Specific Language for selecting rows from a table
9
python,database,algorithm,dsl
0
2008-09-26T14:56:00.000
I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a small subset of rows from a potentially very large table. The exact choice of what ro...
5
0
0
0
false
140,228
0
2,773
6
0
0
140,026
You said nobody is going to want to install a server that downloads and executes arbitrary code at runtime. However, that is exactly what your DSL will do (eventually) so there probably isn't that much of a difference. Unless you're doing something very specific with the data then I don't think a DSL will buy you tha...
1
0
0
Writing a Domain Specific Language for selecting rows from a table
9
python,database,algorithm,dsl
0
2008-09-26T14:56:00.000
I'm writing a server that I expect to be run by many different people, not all of whom I will have direct contact with. The servers will communicate with each other in a cluster. Part of the server's functionality involves selecting a small subset of rows from a potentially very large table. The exact choice of what ro...
5
1
0.022219
0
false
140,275
0
2,773
6
0
0
140,026
I think we're going to need a bit more information here. Let me know if any of the following is based on incorrect assumptions. First of all, as you pointed out yourself, there already exists a DSL for selecting rows from arbitrary tables-- it is called "SQL". Since you don't want to reinvent SQL, I'm assuming that y...
1
0
0
Writing a Domain Specific Language for selecting rows from a table
9
python,database,algorithm,dsl
0
2008-09-26T14:56:00.000
I've seen a number of postgresql modules for python like pygresql, pypgsql, psyco. Most of them are Python DB API 2.0 compliant, some are not being actively developed anymore. Which module do you recommend? Why?
28
0
0
0
false
1,579,851
0
15,582
2
0
0
144,448
I uses only psycopg2 and had no problems with that.
1
0
0
Python PostgreSQL modules. Which is best?
6
python,postgresql,module
0
2008-09-27T20:55:00.000
I've seen a number of postgresql modules for python like pygresql, pypgsql, psyco. Most of them are Python DB API 2.0 compliant, some are not being actively developed anymore. Which module do you recommend? Why?
28
0
0
0
false
145,801
0
15,582
2
0
0
144,448
Psycopg1 is known for better performance in heavilyy threaded environments (like web applications) than Psycopg2, although not maintained. Both are well written and rock solid, I'd choose one of these two depending on use case.
1
0
0
Python PostgreSQL modules. Which is best?
6
python,postgresql,module
0
2008-09-27T20:55:00.000
I'm trying to develop an app using turbogears and sqlalchemy. There is already an existing app using kinterbasdb directly under mod_wsgi on the same server. When both apps are used, neither seems to recognize that kinterbasdb is already initialized Is there something non-obvious I am missing about using sqlalchemy and ...
1
2
0.379949
0
false
175,634
0
270
1
0
0
155,029
I thought I posted my solution already... Modifying both apps to run under WSGIApplicationGroup ${GLOBAL} in their httpd conf file and patching sqlalchemy.databases.firebird.py to check if self.dbapi.initialized is True before calling self.dbapi.init(... was the only way I could manage to get this scenario up and runni...
1
1
0
SQLAlchemy and kinterbasdb in separate apps under mod_wsgi
1
python,sqlalchemy,kinterbasdb
0
2008-09-30T20:47:00.000
I have a table that looks something like this: word big expensive smart fast dog 9 -10 -20 4 professor 2 4 40 -7 ferrari 7 50 0 48 alaska 10 0 1 0 gnat -3 0 0 0 The + and - values are as...
1
0
0
0
false
177,302
0
4,588
1
0
0
177,284
Can you use the built-in database aggregate functions like MAX(column)?
1
0
0
SQL Absolute value across columns
5
python,mysql,sql,oracle,postgresql
0
2008-10-07T05:06:00.000
Sometimes in our production environment occurs situation when connection between service (which is python program that uses MySQLdb) and mysql server is flacky, some packages are lost, some black magic happens and .execute() of MySQLdb.Cursor object never ends (or take great amount of time to end). This is very bad be...
2
2
0.197375
0
false
196,308
0
2,995
2
0
0
196,217
if the communication is such a problem, consider writing a 'proxy' that receives your SQL commands over the flaky connection and relays them to the MySQL server on a reliable channel (maybe running on the same box as the MySQL server). This way you have total control over failure detection and retrying.
1
0
0
MySQLdb execute timeout
2
python,mysql,timeout
0
2008-10-12T22:27:00.000
Sometimes in our production environment occurs situation when connection between service (which is python program that uses MySQLdb) and mysql server is flacky, some packages are lost, some black magic happens and .execute() of MySQLdb.Cursor object never ends (or take great amount of time to end). This is very bad be...
2
1
0.099668
0
false
196,891
0
2,995
2
0
0
196,217
You need to analyse exactly what the problem is. MySQL connections should eventually timeout if the server is gone; TCP keepalives are generally enabled. You may be able to tune the OS-level TCP timeouts. If the database is "flaky", then you definitely need to investigate how. It seems unlikely that the database really...
1
0
0
MySQLdb execute timeout
2
python,mysql,timeout
0
2008-10-12T22:27:00.000
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob? (I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
40
2
0.028564
0
false
198,763
0
31,019
6
0
0
198,692
Since Pickle can dump your object graph to a string it should be possible. Be aware though that TEXT fields in SQLite uses database encoding so you might need to convert it to a simple string before you un-pickle.
1
0
1
Can I pickle a python dictionary into a sqlite3 text field?
14
python,sqlite,pickle
0
2008-10-13T19:11:00.000
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob? (I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
40
5
0.071307
0
false
198,767
0
31,019
6
0
0
198,692
Pickle has both text and binary output formats. If you use the text-based format you can store it in a TEXT field, but it'll have to be a BLOB if you use the (more efficient) binary format.
1
0
1
Can I pickle a python dictionary into a sqlite3 text field?
14
python,sqlite,pickle
0
2008-10-13T19:11:00.000
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob? (I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
40
2
0.028564
0
false
198,770
0
31,019
6
0
0
198,692
If a dictionary can be pickled, it can be stored in text/blob field as well. Just be aware of the dictionaries that can't be pickled (aka that contain unpickable objects).
1
0
1
Can I pickle a python dictionary into a sqlite3 text field?
14
python,sqlite,pickle
0
2008-10-13T19:11:00.000
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob? (I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
40
2
0.028564
0
false
198,829
0
31,019
6
0
0
198,692
Yes, you can store a pickled object in a TEXT or BLOB field in an SQLite3 database, as others have explained. Just be aware that some object cannot be pickled. The built-in container types can (dict, set, list, tuple, etc.). But some objects, such as file handles, refer to state that is external to their own data str...
1
0
1
Can I pickle a python dictionary into a sqlite3 text field?
14
python,sqlite,pickle
0
2008-10-13T19:11:00.000
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob? (I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
40
1
0.014285
0
false
199,190
0
31,019
6
0
0
198,692
SpoonMeiser is correct, you need to have a strong reason to pickle into a database. It's not difficult to write Python objects that implement persistence with SQLite. Then you can use the SQLite CLI to fiddle with the data as well. Which in my experience is worth the extra bit of work, since many debug and admin fu...
1
0
1
Can I pickle a python dictionary into a sqlite3 text field?
14
python,sqlite,pickle
0
2008-10-13T19:11:00.000
Any gotchas I should be aware of? Can I store it in a text field, or do I need to use a blob? (I'm not overly familiar with either pickle or sqlite, so I wanted to make sure I'm barking up the right tree with some of my high-level design ideas.)
40
23
1.2
0
true
198,748
0
31,019
6
0
0
198,692
If you want to store a pickled object, you'll need to use a blob, since it is binary data. However, you can, say, base64 encode the pickled object to get a string that can be stored in a text field. Generally, though, doing this sort of thing is indicative of bad design, since you're storing opaque data you lose the ab...
1
0
1
Can I pickle a python dictionary into a sqlite3 text field?
14
python,sqlite,pickle
0
2008-10-13T19:11:00.000
For a website like reddit with lots of up/down votes and lots of comments per topic what should I go with? Lighttpd/Php or Lighttpd/CherryPy/Genshi/SQLAlchemy? and for database what would scale better / be fastest MySQL ( 4.1 or 5 ? ) or PostgreSQL?
7
2
0.07983
0
false
244,836
1
1,670
4
0
0
204,802
I would go with nginx + php + xcache + postgresql
1
0
0
What would you recommend for a high traffic ajax intensive website?
5
php,python,lighttpd,cherrypy,high-load
0
2008-10-15T13:57:00.000
For a website like reddit with lots of up/down votes and lots of comments per topic what should I go with? Lighttpd/Php or Lighttpd/CherryPy/Genshi/SQLAlchemy? and for database what would scale better / be fastest MySQL ( 4.1 or 5 ? ) or PostgreSQL?
7
2
0.07983
0
false
204,854
1
1,670
4
0
0
204,802
Going to need more data. Jeff had a few articles on the same problems and the answer was to wait till you hit a performance issue. to start with - who is hosting and what do they have available ? what's your in house talent skill sets ? Are you going to be hiring an outside firm ? what do they recommend ? brand new...
1
0
0
What would you recommend for a high traffic ajax intensive website?
5
php,python,lighttpd,cherrypy,high-load
0
2008-10-15T13:57:00.000
For a website like reddit with lots of up/down votes and lots of comments per topic what should I go with? Lighttpd/Php or Lighttpd/CherryPy/Genshi/SQLAlchemy? and for database what would scale better / be fastest MySQL ( 4.1 or 5 ? ) or PostgreSQL?
7
8
1.2
0
true
204,853
1
1,670
4
0
0
204,802
I can't speak to the MySQL/PostgreSQL question as I have limited experience with Postgres, but my Masters research project was about high-performance websites with CherryPy, and I don't think you'll be disappointed if you use CherryPy for your site. It can easily scale to thousands of simultaneous users on commodity h...
1
0
0
What would you recommend for a high traffic ajax intensive website?
5
php,python,lighttpd,cherrypy,high-load
0
2008-10-15T13:57:00.000
For a website like reddit with lots of up/down votes and lots of comments per topic what should I go with? Lighttpd/Php or Lighttpd/CherryPy/Genshi/SQLAlchemy? and for database what would scale better / be fastest MySQL ( 4.1 or 5 ? ) or PostgreSQL?
7
3
0.119427
0
false
205,425
1
1,670
4
0
0
204,802
On the DB question, I'd say PostgreSQL scales better and has better data integrity than MySQL. For a small site MySQL might be faster, but from what I've heard it slows significantly as the size of the database grows. (Note: I've never used MySQL for a large database, so you should probably get a second opinion about i...
1
0
0
What would you recommend for a high traffic ajax intensive website?
5
php,python,lighttpd,cherrypy,high-load
0
2008-10-15T13:57:00.000
I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in produc...
13
0
0
0
false
214,623
0
31,269
5
0
0
211,501
Yes, I was nuking out the problem. All I needed to do was check for the file and catch the IOError if it didn't exist. Thanks for all the other answers. They may come in handy in the future.
1
0
0
Using SQLite in a Python program
8
python,exception,sqlite
0
2008-10-17T09:02:00.000
I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in produc...
13
3
0.07486
0
false
211,539
0
31,269
5
0
0
211,501
Doing SQL in overall is horrible in any language I've picked up. SQLalchemy has shown to be easiest from them to use because actual query and committing with it is so clean and absent from troubles. Here's some basic steps on actually using sqlalchemy in your app, better details can be found from the documentation. pr...
1
0
0
Using SQLite in a Python program
8
python,exception,sqlite
0
2008-10-17T09:02:00.000
I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in produc...
13
7
1
0
false
211,573
0
31,269
5
0
0
211,501
SQLite automatically creates the database file the first time you try to use it. The SQL statements for creating tables can use IF NOT EXISTS to make the commands only take effect if the table has not been created This way you don't need to check for the database's existence beforehand: SQLite can take care of that for...
1
0
0
Using SQLite in a Python program
8
python,exception,sqlite
0
2008-10-17T09:02:00.000
I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in produc...
13
29
1
0
false
211,660
0
31,269
5
0
0
211,501
Don't make this more complex than it needs to be. The big, independent databases have complex setup and configuration requirements. SQLite is just a file you access with SQL, it's much simpler. Do the following. Add a table to your database for "Components" or "Versions" or "Configuration" or "Release" or something ...
1
0
0
Using SQLite in a Python program
8
python,exception,sqlite
0
2008-10-17T09:02:00.000
I have created a Python module that creates and populates several SQLite tables. Now, I want to use it in a program but I don't really know how to call it properly. All the tutorials I've found are essentially "inline", i.e. they walk through using SQLite in a linear fashion rather than how to actually use it in produc...
13
13
1.2
0
true
211,534
0
31,269
5
0
0
211,501
AFAIK an SQLITE database is just a file. To check if the database exists, check for file existence. When you open a SQLITE database it will automatically create one if the file that backs it up is not in place. If you try and open a file as a sqlite3 database that is NOT a database, you will get this: "sqlite3.Database...
1
0
0
Using SQLite in a Python program
8
python,exception,sqlite
0
2008-10-17T09:02:00.000
From what I understand, the parent attribute of a db.Model (typically defined/passed in the constructor call) allows you to define hierarchies in your data models. As a result, this increases the size of the entity group. However, it's not very clear to me why we would want to do that. Is this strictly for ACID complia...
10
15
1.2
0
true
216,187
1
1,067
1
1
0
215,570
There are several differences: All entities with the same ancestor are in the same entity group. Transactions can only affect entities inside a single entity group. All writes to a single entity group are serialized, so throughput is limited. The parent entity is set on creation and is fixed. References can be changed...
1
0
0
What's the difference between a parent and a reference property in Google App Engine?
2
python,api,google-app-engine
0
2008-10-18T21:12:00.000
I need to update data to a mssql 2005 database so I have decided to use adodbapi, which is supposed to come built into the standard installation of python 2.1.1 and greater. It needs pywin32 to work correctly and the open office python 2.3 installation does not have pywin32 built into it. It also seems like this built ...
0
1
0.066568
0
false
239,487
0
833
1
0
0
239,009
maybe the best way to install pywin32 is to place it in (openofficedir)\program\python-core-2.3.4\lib\site-packages it is easy if you have a python 2.3 installation (with pywin installed) under C:\python2.3 move the C:\python2.3\Lib\site-packages\ to your (openofficedir)\program\python-core-2.3.4\lib\site-packages
1
0
0
getting pywin32 to work inside open office 2.4 built in python 2.3 interpreter
3
python,openoffice.org,pywin32,adodbapi
0
2008-10-27T03:32:00.000
With SQLAlchemy, is there a way to know beforehand whether a relation would be lazy-loaded? For example, given a lazy parent->children relation and an instance X of "parent", I'd like to know if "X.children" is already loaded, without triggering the query.
16
5
1.2
0
true
261,191
0
3,701
1
0
0
258,775
I think you could look at the child's __dict__ attribute dictionary to check if the data is already there or not.
1
0
0
How to find out if a lazy relation isn't loaded yet, with SQLAlchemy?
3
python,sqlalchemy
0
2008-11-03T14:28:00.000
I want to make my Python library working with MySQLdb be able to detect deadlocks and try again. I believe I've coded a good solution, and now I want to test it. Any ideas for the simplest queries I could run using MySQLdb to create a deadlock condition would be? system info: MySQL 5.0.19 Client 5.1.11 Windows XP P...
10
1
0.039979
0
false
270,449
0
7,080
1
0
0
269,676
you can always run LOCK TABLE tablename from another session (mysql CLI for instance). That might do the trick. It will remain locked until you release it or disconnect the session.
1
0
0
How can I Cause a Deadlock in MySQL for Testing Purposes
5
python,mysql,database,deadlock
0
2008-11-06T18:06:00.000
I'm starting a web project that likely should be fine with SQLite. I have SQLObject on top of it, but thinking long term here -- if this project should require a more robust (e.g. able to handle high traffic), I will need to have a transition plan ready. My questions: How easy is it to transition from one DB (SQLite...
1
2
0.132549
0
false
275,676
0
876
1
0
0
275,572
Your success with createTable() will depend on your existing underlying table schema / data types. In other words, how well SQLite maps to the database you choose and how SQLObject decides to use your data types. The safest option may be to create the new database by hand. Then you'll have to deal with data migration...
1
0
0
Database change underneath SQLObject
3
python,mysql,database,sqlite,sqlobject
0
2008-11-09T03:46:00.000
I am having a postgres production database in production (which contains a lot of Data). now I need to modify the model of the tg-app to add couple of new tables to the database. How do i do this? I am using sqlAlchemy.
1
1
1.2
0
true
301,708
1
889
1
0
0
301,566
This always works and requires little thinking -- only patience. Make a backup. Actually make a backup. Everyone skips step 1 thinking that they have a backup, but they can never find it or work with it. Don't trust any backup that you can't recover from. Create a new database schema. Define your new structure from ...
1
0
0
How to update turbogears application production database
4
python,database,postgresql,data-migration,turbogears
0
2008-11-19T11:00:00.000
I'm using Django and Python 2.6, and I want to grow my application using a MySQL backend. Problem is that there isn't a win32 package for MySQLdb on Python 2.6. Now I'm no hacker, but I thought I might compile it myself using MSVC++9 Express. But I run into a problem that the compiler quickly can't find config_win.h,...
9
2
1.2
0
true
317,716
0
3,446
1
0
0
316,484
I think that the header files are shipped with MySQL, just make sure you check the appropriate options when installing (I think that sources and headers are under "developer components" in the installation dialog).
1
0
0
Problem compiling MySQLdb for Python 2.6 on Win32
4
python,mysql,winapi
0
2008-11-25T06:14:00.000
What is the sqlalchemy equivalent column type for 'money' and 'OID' column types in Postgres?
8
3
1.2
0
true
405,923
0
10,565
1
0
0
359,409
we've never had an "OID" type specifically, though we've supported the concept of an implicit "OID" column on every table through the 0.4 series, primarily for the benefit of postgres. However since user-table defined OID columns are deprecated in Postgres, and we in fact never really used the OID feature that was pre...
1
0
0
What is the sqlalchemy equivalent column type for 'money' and 'OID' in Postgres?
3
python,postgresql,sqlalchemy
0
2008-12-11T13:52:00.000
How do I connect to a MySQL database using a python program?
1,242
1
0.008
0
false
64,762,149
0
1,369,727
1
0
0
372,885
First step to get The Library: Open terminal and execute pip install mysql-python-connector. After the installation go the second step. Second Step to import the library: Open your python file and write the following code: import mysql.connector Third step to connect to the server: Write the following code: conn = mys...
1
0
0
How do I connect to a MySQL Database in Python?
25
python,mysql
0
2008-12-16T21:49:00.000
So, looking for a mysql-db-lib that is compatible with py3k/py3.0/py3000, any ideas? Google turned up nothing.
36
0
0
0
false
385,225
0
43,916
1
0
0
384,471
You're probably better off using Python 2.x at the moment. It's going to be a while before all Python packages are ported to 3.x, and I expect writing a library or application with 3.x at the moment would be quite frustrating.
1
0
0
MySQL-db lib for Python 3.x?
9
python,mysql,python-3.x
0
2008-12-21T13:37:00.000
I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me?
1
0
0
0
false
387,800
0
4,847
3
0
0
387,606
To start with, treat the barcode input as plain old text. It has been quite a while since I worked with barcode scanners, but I doubt they have changed that much, the older ones used to just piggyback on the keyboard input, so from a programming perspective, the net result was a stream of characters in the keyboard ...
1
0
0
Using user input to find information in a Mysql database
4
python,sql,user-input
0
2008-12-22T22:37:00.000
I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me?
1
1
0.049958
0
false
387,622
0
4,847
3
0
0
387,606
A barcode is simply a graphical representation of a series of characters (alphanumeric) So if you have a method for users to enter this code (a barcode scanner), then its just an issue of querying the mysql database for the character string.
1
0
0
Using user input to find information in a Mysql database
4
python,sql,user-input
0
2008-12-22T22:37:00.000
I need to design a program using python that will ask the user for a barcode. Then, using this barcode, it will search a mysql to find its corresponding product. I am a bit stuck on how to get started. Does anyone have any tips for me?
1
0
0
0
false
387,694
0
4,847
3
0
0
387,606
That is a very ambiguous question. What you want can be done in many ways depending on what you actually want to do. How are your users going to enter the bar code? Are they going to use a bar code scanner? Are they entering the bar code numbers manually? Is this going to run on a desktop/laptop computer or is it goin...
1
0
0
Using user input to find information in a Mysql database
4
python,sql,user-input
0
2008-12-22T22:37:00.000
I'm writing a script in python which basically queries WMI and updates the information in a mysql database. One of those "write something you need" to learn to program exercises. In case something breaks in the middle of the script, for example, the remote computer turns off, it's separated out into functions. Query S...
2
7
1.2
0
true
387,932
0
1,201
3
0
0
387,619
"However, opening and closing the connection with each update seems more 'neat'. " It's also a huge amount of overhead -- and there's no actual benefit. Creating and disposing of connections is relatively expensive. More importantly, what's the actual reason? How does it improve, simplify, clarify? Generally, most a...
1
0
0
Mysql Connection, one or many?
4
python,mysql
0
2008-12-22T22:40:00.000
I'm writing a script in python which basically queries WMI and updates the information in a mysql database. One of those "write something you need" to learn to program exercises. In case something breaks in the middle of the script, for example, the remote computer turns off, it's separated out into functions. Query S...
2
2
0.099668
0
false
387,735
0
1,201
3
0
0
387,619
I don't think that there is "better" solution. Its too early to think about resources. And since wmi is quite slow ( in comparison to sql connection ) the db is not an issue. Just make it work. And then make it better. The good thing about working with open connection here, is that the "natural" solution is to use obje...
1
0
0
Mysql Connection, one or many?
4
python,mysql
0
2008-12-22T22:40:00.000
I'm writing a script in python which basically queries WMI and updates the information in a mysql database. One of those "write something you need" to learn to program exercises. In case something breaks in the middle of the script, for example, the remote computer turns off, it's separated out into functions. Query S...
2
1
0.049958
0
false
389,364
0
1,201
3
0
0
387,619
Useful clues in S.Lott's and Igal Serban's answers. I think you should first find out your actual requirements and code accordingly. Just to mention a different strategy; some applications keep a pool of database (or whatever) connections and in case of a transaction just pull one from that pool. It seems rather obviou...
1
0
0
Mysql Connection, one or many?
4
python,mysql
0
2008-12-22T22:40:00.000
I am using python to read a currency value from excel. The returned from the range.Value method is a tuple that I don't know how to parse. For example, the cell appears as $548,982, but in python the value is returned as (1, 1194857614). How can I get the numerical amount from excel or how can I convert this tuple valu...
1
0
0
0
false
390,304
0
586
1
0
0
390,263
I tried this with Excel 2007 and VBA. It is giving correct value. 1) Try pasting this value in a new excel workbook 2) Press Alt + F11. Gets you to VBA Editor. 3) Press Ctrl + G. Gets you to immediate window. 4) In the immediate window, type ?cells("a1").Value here "a1" is the cell where you have pasted the value. I ...
1
0
1
Interpreting Excel Currency Values
2
python,excel,pywin32
0
2008-12-23T22:37:00.000
I am currently analyzing a wikipedia dump file; I am extracting a bunch of data from it using python and persisting it into a PostgreSQL db. I am always trying to make things go faster for this file is huge (18GB). In order to interface with PostgreSQL, I am using psycopg2, but this module seems to mimic many other suc...
6
-1
-0.049958
0
false
675,865
0
7,742
2
0
0
396,455
using a MERGE statement instead of an INSERT one would solve your problem.
1
0
0
Python-PostgreSQL psycopg2 interface --> executemany
4
python,postgresql,database,psycopg
0
2008-12-28T17:51:00.000
I am currently analyzing a wikipedia dump file; I am extracting a bunch of data from it using python and persisting it into a PostgreSQL db. I am always trying to make things go faster for this file is huge (18GB). In order to interface with PostgreSQL, I am using psycopg2, but this module seems to mimic many other suc...
6
0
0
0
false
396,824
0
7,742
2
0
0
396,455
"When my script detects such a non-UNIQUE INSERT, it connection.rollback() (which makes ups to 1000 rows everytime, and kind of makes the executemany worthless) and then INSERTs all values one by one." The question doesn't really make a lot of sense. Does EVERY block of 1,000 rows fail due to non-unique rows? Does 1 b...
1
0
0
Python-PostgreSQL psycopg2 interface --> executemany
4
python,postgresql,database,psycopg
0
2008-12-28T17:51:00.000
I'm wondering, is it possible to make an sql query that does the same function as 'select products where barcode in table1 = barcode in table2'. I am writing this function in a python program. Once that function is called will the table be joined permanently or just while that function is running? thanks.
0
0
0
0
false
403,848
0
680
2
0
0
403,527
Here is an example of inner joining two tables based on a common field in both tables. SELECT table1.Products FROM table1 INNER JOIN table2 on table1.barcode = table2.barcode WHERE table1.Products is not null
1
0
0
Making a SQL Query in two tables
6
python,sql
0
2008-12-31T17:20:00.000
I'm wondering, is it possible to make an sql query that does the same function as 'select products where barcode in table1 = barcode in table2'. I am writing this function in a python program. Once that function is called will the table be joined permanently or just while that function is running? thanks.
0
0
0
0
false
403,904
0
680
2
0
0
403,527
Here's a way to talk yourself through table design in these cases, based on Object Role Modeling. (Yes, I realize this is only indirectly related to the question.) You have products and barcodes. Products are uniquely identified by Product Code (e.g. 'A2111'; barcodes are uniquely identified by Value (e.g. 1002155061)....
1
0
0
Making a SQL Query in two tables
6
python,sql
0
2008-12-31T17:20:00.000
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
13
5
1.2
0
true
413,259
1
15,364
4
0
0
413,228
For what it's worth, django uses psycopg2.
1
0
0
PyGreSQL vs psycopg2
5
python,postgresql
0
2009-01-05T14:21:00.000
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
13
0
0
0
false
413,508
1
15,364
4
0
0
413,228
psycopg2 is partly written in C so you can expect a performance gain, but on the other hand, a bit harder to install. PyGreSQL is written in Python only, easy to deployed but slower.
1
0
0
PyGreSQL vs psycopg2
5
python,postgresql
0
2009-01-05T14:21:00.000
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
13
4
0.158649
0
false
592,846
1
15,364
4
0
0
413,228
"PyGreSQL is written in Python only, easy to deployed but slower." PyGreSQL contains a C-coded module, too. I haven't done speed tests, but they're not likely to be much different, as the real work will happen inside the database server.
1
0
0
PyGreSQL vs psycopg2
5
python,postgresql
0
2009-01-05T14:21:00.000
What is the difference between these two apis? Which one faster, reliable using Python DB API? Upd: I see two psql drivers for Django. The first one is psycopg2. What is the second one? pygresql?
13
2
0.07983
0
false
413,537
1
15,364
4
0
0
413,228
Licensing may be an issue for you. PyGreSQL is MIT license. Psycopg2 is GPL license. (as long as you are accessing psycopg2 in normal ways from Python, with no internal API, and no direct C calls, this shouldn't cause you any headaches, and you can release your code under whatever license you like - but I am not a lawy...
1
0
0
PyGreSQL vs psycopg2
5
python,postgresql
0
2009-01-05T14:21:00.000
The beauty of ORM lulled me into a soporific sleep. I've got an existing Django app with a lack of database indexes. Is there a way to automatically generate a list of columns that need indexing? I was thinking maybe some middleware that logs which columns are involved in WHERE clauses? but is there anything built into...
5
4
0.379949
0
false
438,700
1
620
1
0
0
438,559
No. Adding indexes willy-nilly to all "slow" queries will also slow down inserts, updates and deletes. Indexes are a balancing act between fast queries and fast changes. There is no general or "right" answer. There's certainly nothing that can automate this. You have to measure the improvement across your whole appli...
1
0
0
Is there a way to automatically generate a list of columns that need indexing?
2
python,mysql,database,django,django-models
0
2009-01-13T10:36:00.000
I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are proble...
2
0
0
0
false
494,119
0
2,512
6
0
0
439,759
Just to throw it out there... there are PHP frameworks utilizing MVC. Codeigniter does simple and yet powerful things. You can definitely separate the template layer from the logic layer.
1
0
0
Is a PHP, Python, PostgreSQL design suitable for a business application?
7
php,python,postgresql
0
2009-01-13T16:47:00.000
I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are proble...
2
0
0
0
false
439,793
0
2,512
6
0
0
439,759
I personally agree with the second and the third points in your post. Speaking about PHP, in my opinion you can use Python also for presentation, there are many solutions (Zope, Plone ...) based on Python.
1
0
0
Is a PHP, Python, PostgreSQL design suitable for a business application?
7
php,python,postgresql
0
2009-01-13T16:47:00.000
I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are proble...
2
0
0
0
false
439,818
0
2,512
6
0
0
439,759
Just skip PHP and use Python (with Django, as already noticed while I typed). Django already separates the layers as you mentioned. I have never used PgSQL myself, but I think it's mostly a matter of taste whether you prefer it over MySQL. It used to support more enterprise features than MySQL but I'm not sure if that'...
1
0
0
Is a PHP, Python, PostgreSQL design suitable for a business application?
7
php,python,postgresql
0
2009-01-13T16:47:00.000
I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are proble...
2
1
0.028564
0
false
440,496
0
2,512
6
0
0
439,759
I can only repeat what other peoples here already said : if you choose Python for the domain layer, you won't gain anything (quite on the contrary) using PHP for the presentation layer. Others already advised Django, and that might be a pretty good choice, but there's no shortage of good Python web frameworks.
1
0
0
Is a PHP, Python, PostgreSQL design suitable for a business application?
7
php,python,postgresql
0
2009-01-13T16:47:00.000
I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are proble...
2
1
0.028564
0
false
440,118
0
2,512
6
0
0
439,759
I'm going to assume that by "business application" you mean a web application hosted in an intranet environment as opposed to some sort of SaaS application on the internet. While you're in the process of architecting your application you need to consider the existing infrastructure and infrastructure support people of ...
1
0
0
Is a PHP, Python, PostgreSQL design suitable for a business application?
7
php,python,postgresql
0
2009-01-13T16:47:00.000
I'm looking for some quick thoughts about a business application I am looking to build. I'd like to separate the three layers of presentation, domain logic, and data using PHP, Python, and PostgreSQL, respectively. I would like to hear, possibly from other folks who have gone down this path before, if there are proble...
2
0
0
0
false
440,098
0
2,512
6
0
0
439,759
Just to address the MySQL vs PgSQL issues - it shouldn't matter. They're both more than capable of the task, and any reasonable framework should isolate you from the differences relatively well. I think it's down to what you use already, what people have most experience in, and if there's a feature in one or the other ...
1
0
0
Is a PHP, Python, PostgreSQL design suitable for a business application?
7
php,python,postgresql
0
2009-01-13T16:47:00.000
Example Problem: Entities: User contains name and a list of friends (User references) Blog Post contains title, content, date and Writer (User) Requirement: I want a page that displays the title and a link to the blog of the last 10 posts by a user's friend. I would also like the ability to keep paging back through ...
13
13
1
0
false
446,471
1
2,112
2
1
0
445,827
If you look at how the SQL solution you provided will be executed, it will go basically like this: Fetch a list of friends for the current user For each user in the list, start an index scan over recent posts Merge-join all the scans from step 2, stopping when you've retrieved enough entries You can carry out exactly...
1
0
0
GAE - How to live with no joins?
4
python,google-app-engine,join,google-cloud-datastore
0
2009-01-15T06:07:00.000
Example Problem: Entities: User contains name and a list of friends (User references) Blog Post contains title, content, date and Writer (User) Requirement: I want a page that displays the title and a link to the blog of the last 10 posts by a user's friend. I would also like the ability to keep paging back through ...
13
1
0.049958
0
false
446,477
1
2,112
2
1
0
445,827
"Load user, loop through the list of friends and load their latest blog posts." That's all a join is -- nested loops. Some kinds of joins are loops with lookups. Most lookups are just loops; some are hashes. "Finally merge all the blog posts to find the latest 10 blog entries" That's a ORDER BY with a LIMIT. That's ...
1
0
0
GAE - How to live with no joins?
4
python,google-app-engine,join,google-cloud-datastore
0
2009-01-15T06:07:00.000
I am using plone.app.blob to store large ZODB objects in a blobstorage directory. This reduces size pressure on Data.fs but I have not been able to find any advice on backing up this data. I am already backing up Data.fs by pointing a network backup tool at a directory of repozo backups. Should I simply point that tool...
8
13
1
0
false
2,664,479
0
2,618
3
0
0
451,952
It should be safe to do a repozo backup of the Data.fs followed by an rsync of the blobstorage directory, as long as the database doesn't get packed while those two operations are happening. This is because, at least when using blobs with FileStorage, modifications to a blob always results in the creation of a new file...
1
0
0
What is the correct way to backup ZODB blobs?
4
python,plone,zope,zodb,blobstorage
0
2009-01-16T20:51:00.000
I am using plone.app.blob to store large ZODB objects in a blobstorage directory. This reduces size pressure on Data.fs but I have not been able to find any advice on backing up this data. I am already backing up Data.fs by pointing a network backup tool at a directory of repozo backups. Should I simply point that tool...
8
3
1.2
0
true
453,942
0
2,618
3
0
0
451,952
Backing up "blobstorage" will do it. No need for a special order or anything else, it's very simple. All operations in Plone are fully transactional, so hitting the backup in the middle of a transaction should work just fine. This is why you can do live backups of the ZODB. Without knowing what file system you're on, I...
1
0
0
What is the correct way to backup ZODB blobs?
4
python,plone,zope,zodb,blobstorage
0
2009-01-16T20:51:00.000
I am using plone.app.blob to store large ZODB objects in a blobstorage directory. This reduces size pressure on Data.fs but I have not been able to find any advice on backing up this data. I am already backing up Data.fs by pointing a network backup tool at a directory of repozo backups. Should I simply point that tool...
8
1
0.049958
0
false
676,364
0
2,618
3
0
0
451,952
Your backup strategy for the FileStorage is fine. However, making a backup of any database that stores data in multiple files never is easy as your copy has to happen with no writes to the various files. For the FileStorage a blind stupid copy is fine as it's just a single file. (Using repozo is even better.) In this c...
1
0
0
What is the correct way to backup ZODB blobs?
4
python,plone,zope,zodb,blobstorage
0
2009-01-16T20:51:00.000
I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
493
5
0.03124
0
false
28,278,997
1
804,257
5
0
0
454,854
Go to your project directory with cd. source/bin/activate (activate your env. if not previously). Run the command easy_install MySQL-python
1
0
0
No module named MySQLdb
32
python,django,python-2.x
0
2009-01-18T09:13:00.000
I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
493
6
1
0
false
58,246,337
1
804,257
5
0
0
454,854
I personally recommend using pymysql instead of using the genuine MySQL connector, which provides you with a platform independent interface and could be installed through pip. And you could edit the SQLAlchemy URL schema like this: mysql+pymysql://username:passwd@host/database
1
0
0
No module named MySQLdb
32
python,django,python-2.x
0
2009-01-18T09:13:00.000
I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
493
93
1
0
false
38,310,817
1
804,257
5
0
0
454,854
if your python version is 3.5, do a pip install mysqlclient, other things didn't work for me
1
0
0
No module named MySQLdb
32
python,django,python-2.x
0
2009-01-18T09:13:00.000
I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
493
2
0.012499
0
false
58,825,148
1
804,257
5
0
0
454,854
None of the above worked for me on an Ubuntu 18.04 fresh install via docker image. The following solved it for me: apt-get install holland python3-mysqldb
1
0
0
No module named MySQLdb
32
python,django,python-2.x
0
2009-01-18T09:13:00.000
I am using Python version 2.5.4 and install MySQL version 5.0 and Django. Django is working fine with Python, but not MySQL. I am using it in Windows Vista.
493
0
0
0
false
72,496,371
1
804,257
5
0
0
454,854
For CentOS 8 and Python3 $ sudo dnf install python3-mysqlclient -y
1
0
0
No module named MySQLdb
32
python,django,python-2.x
0
2009-01-18T09:13:00.000
I think I am being a bonehead, maybe not importing the right package, but when I do... from pysqlite2 import dbapi2 as sqlite import types import re import sys ... def create_asgn(self): stmt = "CREATE TABLE ? (login CHAR(8) PRIMARY KEY NOT NULL, grade INTEGER NOT NULL)" stmt2 = "insert into asgn v...
1
7
1.2
0
true
474,296
0
1,629
1
0
0
474,261
That's because parameters can only be passed to VALUES. The table name can't be parametrized. Also you have quotes around a parametrized argument on the second query. Remove the quotes, escaping is handled by the underlining library automatically for you.
1
0
0
Python pysqlite not accepting my qmark parameterization
3
python,sqlite,pysqlite,python-db-api
0
2009-01-23T19:55:00.000
I have been working with PostgreSQL, playing around with Wikipedia's millions of hyperlinks and such, for 2 years now. I either do my thing directly by sending SQL commands, or I write a client side script in python to manage a million queries when this cannot be done productively (efficiently and effectively) manually...
3
1
0.066568
0
false
476,089
0
2,801
2
0
0
475,302
I was in the exact same situation as you and went with PL/Python after giving up on PL/SQL after a while. It was a good decision, looking back. Some things that bit me where unicode issues (client encoding, byte sequence) and specific postgres data types (bytea).
1
0
0
PostgreSQL procedural languages: to choose?
3
python,postgresql
0
2009-01-24T01:38:00.000
I have been working with PostgreSQL, playing around with Wikipedia's millions of hyperlinks and such, for 2 years now. I either do my thing directly by sending SQL commands, or I write a client side script in python to manage a million queries when this cannot be done productively (efficiently and effectively) manually...
3
2
0.132549
0
false
475,939
0
2,801
2
0
0
475,302
Why can't you run your Python on the database server? That has the fewest complexities -- you can run the program you already have.
1
0
0
PostgreSQL procedural languages: to choose?
3
python,postgresql
0
2009-01-24T01:38:00.000
Is there a good ORM (object relational manager) solution that can use the same database from C++, C#, Python? It could also be multiple solutions, e.g. one per language, as long as they can can access the same database and use the same schema. Multi platform support is also needed. Clarification: The idea is to have on...
7
0
0
0
false
496,166
0
1,697
2
0
0
482,612
We have an O/RM that has C++ and C# (actually COM) bindings (in FOST.3) and we're putting together the Python bindings which are new in version 4 together with Linux and Mac support.
1
0
0
ORM (object relational manager) solution with multiple programming language support
3
c#,c++,python,orm
0
2009-01-27T08:10:00.000
Is there a good ORM (object relational manager) solution that can use the same database from C++, C#, Python? It could also be multiple solutions, e.g. one per language, as long as they can can access the same database and use the same schema. Multi platform support is also needed. Clarification: The idea is to have on...
7
1
0.066568
0
false
482,653
0
1,697
2
0
0
482,612
With SQLAlchemy, you can use reflection to get the schema, so it should work with any of the supported engines. I've used this to migrate data from an old SQLite to Postgres.
1
0
0
ORM (object relational manager) solution with multiple programming language support
3
c#,c++,python,orm
0
2009-01-27T08:10:00.000
Here is the situation: I have a parent model say BlogPost. It has many Comments. What I want is the list of BlogPosts ordered by the creation date of its' Comments. I.e. the blog post which has the most newest comment should be on top of the list. Is this possible with SQLAlchemy?
3
1
0.099668
0
false
1,227,979
1
595
1
0
0
492,223
I had the same question as the parent when using the ORM, and GHZ's link contained the answer on how it's possible. In sqlalchemy, assuming BlogPost.comments is a mapped relation to the Comments table, you can't do: session.query(BlogPost).order_by(BlogPost.comments.creationDate.desc()) , but you can do: session.que...
1
0
0
How can I order objects according to some attribute of the child in sqlalchemy?
2
python,sqlalchemy
0
2009-01-29T16:01:00.000
I have a small project I am doing in Python using web.py. It's a name generator, using 4 "parts" of a name (firstname, middlename, anothername, surname). Each part of the name is a collection of entites in a MySQL databse (name_part (id, part, type_id), and name_part_type (id, description)). Basic stuff, I guess. My ge...
4
1
0.099668
0
false
514,643
0
1,758
1
0
0
514,617
I agree with your intuition that using a stored procedure is the right way to go, but then, I almost always try to implement database stuff in the database. In your proc, I would introduce some kind of logic like say, there's only a 30% chance that returning the result will actually increment the counter. Just to incre...
1
0
0
Random name generator strategy - help me improve it
2
python,mysql,random,web.py
0
2009-02-05T04:51:00.000
I've got a legacy application which is implemented in a number of Excel workbooks. It's not something that I have the authority to re-implement, however another application that I do maintain does need to be able to call functions in the Excel workbook. It's been given a python interface using the Win32Com library. Ot...
6
0
0
0
false
516,983
0
4,391
1
0
0
516,946
If you application uses a single excel file which contains macros which you call, I fear the answer is probably no since aside from COM Excel does not allow the same file to be opened with the same name (even if in different directories). You may be able to get around this by dynamically copying the file to another na...
1
0
1
Control 2 separate Excel instances by COM independently... can it be done?
3
python,windows,excel,com
0
2009-02-05T17:32:00.000
I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php...
22
3
0.197375
0
false
15,046,529
0
27,905
3
0
0
519,296
Make sure your db connection command isn't in any kind of loop. I was getting the same error from my script until I moved my db.database() out of my programs repeating execution loop.
1
0
0
Getting OperationalError: FATAL: sorry, too many clients already using psycopg2
3
python,postgresql,psycopg2
0
2009-02-06T06:15:00.000
I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php...
22
15
1.2
0
true
519,304
0
27,905
3
0
0
519,296
This error means what it says, there are too many clients connected to postgreSQL. Questions you should ask yourself: Are you the only one connected to this database? Are you running a graphical IDE? What method are you using to connect? Are you testing queries at the same time that you running the code? Any of these...
1
0
0
Getting OperationalError: FATAL: sorry, too many clients already using psycopg2
3
python,postgresql,psycopg2
0
2009-02-06T06:15:00.000
I am getting the error OperationalError: FATAL: sorry, too many clients already when using psycopg2. I am calling the close method on my connection instance after I am done with it. I am not sure what could be causing this, it is my first experience with python and postgresql, but I have a few years experience with php...
22
1
0.066568
0
false
64,746,356
0
27,905
3
0
0
519,296
It simple means many clients are making transaction to PostgreSQL at same time. I was running Postgis container and Django in different docker container. Hence for my case restarting both db and system container solved the problem.
1
0
0
Getting OperationalError: FATAL: sorry, too many clients already using psycopg2
3
python,postgresql,psycopg2
0
2009-02-06T06:15:00.000
I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas...
9
0
0
0
false
524,955
0
13,542
4
0
0
524,797
Depending on the data rate sqlite could be exactly the correct way to do this. The entire database is locked for each write so you aren't going to scale to 1000s of simultaneous writes per second. But if you only have a few it is the safest way of assuring you don't overwrite each other.
1
0
0
Python, SQLite and threading
6
python,multithreading,sqlite
0
2009-02-07T23:18:00.000
I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas...
9
0
0
0
false
524,937
0
13,542
4
0
0
524,797
Depending on the application the DB could be a real overhead. If we are talking about volatile data, maybe you could skip the communication via DB completely and share the data between the data gathering process and the data serving process(es) via IPC. This is not an option if the data has to be persisted, of course...
1
0
0
Python, SQLite and threading
6
python,multithreading,sqlite
0
2009-02-07T23:18:00.000
I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas...
9
8
1.2
0
true
524,806
0
13,542
4
0
0
524,797
Short answer: Don't use Sqlite3 in a threaded application. Sqlite3 databases scale well for size, but rather terribly for concurrency. You will be plagued with "Database is locked" errors. If you do, you will need a connection per thread, and you have to ensure that these connections clean up after themselves. This is ...
1
0
0
Python, SQLite and threading
6
python,multithreading,sqlite
0
2009-02-07T23:18:00.000
I'm working on an application that will gather data through HTTP from several places, cache the data locally and then serve it through HTTP. So I was looking at the following. My application will first create several threads that will gather data at a specified interval and cache that data locally into a SQLite databas...
9
1
0.033321
0
false
524,901
0
13,542
4
0
0
524,797
"...create several threads that will gather data at a specified interval and cache that data locally into a sqlite database. Then in the main thread start a CherryPy app that will query that sqlite db and serve the data." Don't waste a lot of time on threads. The things you're describing are simply OS processes. Just...
1
0
0
Python, SQLite and threading
6
python,multithreading,sqlite
0
2009-02-07T23:18:00.000
I get "database table is locked" error in my sqlite3 db. My script is single threaded, no other app is using the program (i did have it open once in "SQLite Database Browser.exe"). I copied the file, del the original (success) and renamed the copy so i know no process is locking it yet when i run my script everything i...
3
0
0
0
false
6,345,495
0
5,791
1
0
0
531,711
I've also seen this error when the db file is on an NFS mounted file system.
1
0
0
python, sqlite error? db is locked? but it isnt?
4
python,sqlite,locking
0
2009-02-10T09:50:00.000
All I want to do is serialize and unserialize tuples of strings or ints. I looked at pickle.dumps() but the byte overhead is significant. Basically it looks like it takes up about 4x as much space as it needs to. Besides, all I need is basic types and have no need to serialize objects. marshal is a little better in ter...
7
0
0
0
false
532,989
0
2,674
1
0
0
532,934
"the byte overhead is significant" Why does this matter? It does the job. If you're running low on disk space, I'd be glad to sell you a 1Tb for $500. Have you run it? Is performance a problem? Can you demonstrate that the performance of serialization is the problem? "I thought of just using repr() and eval(), bu...
1
0
1
Lightweight pickle for basic types in python?
7
python,serialization,pickle
0
2009-02-10T16:03:00.000
I want to fetch data from a mysql database using sqlalchemy and use the data in a different class.. Basically I fetch a row at a time, use the data, fetch another row, use the data and so on.. I am running into some problem doing this.. Basically, how do I output data a row at a time from mysql data?.. I have looked i...
0
1
0.099668
0
false
536,269
0
563
1
0
0
536,051
Exactly what problems are you running into? You can simply iterate over the ResultProxy object: for row in conn_or_sess_or_engine.execute(selectable_obj_or_SQLstring): do_something_with(row)
1
0
0
Outputting data a row at a time from mysql using sqlalchemy
2
python,mysql,sqlalchemy
0
2009-02-11T09:19:00.000
I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat...
0
1
0.024995
0
false
558,822
0
330
5
0
0
557,199
Here are a couple points for you to consider. If your data is large reading it all into memory may be wasteful. If you need random access and not just sequential access to your data then you'll either have to scan the at most the entire file each time or read that table into an indexed memory structure like a diction...
1
0
0
Converting a database-driven (non-OO) python script into a non-database driven, OO-script
8
python,object
0
2009-02-17T14:56:00.000
I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat...
0
5
1.2
0
true
557,473
0
330
5
0
0
557,199
If the data is a natural fit for database tables ("rectangular data"), why not convert it to sqlite? It's portable -- just one file to move the db around, and sqlite is available anywhere you have python (2.5 and above anyway).
1
0
0
Converting a database-driven (non-OO) python script into a non-database driven, OO-script
8
python,object
0
2009-02-17T14:56:00.000
I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat...
0
1
0.024995
0
false
557,279
0
330
5
0
0
557,199
you could have a fruit class with id and name instance variables. and a function to read/write the information from a file, and maybe a class variable to keep track of the number of fruits (objects) created
1
0
0
Converting a database-driven (non-OO) python script into a non-database driven, OO-script
8
python,object
0
2009-02-17T14:56:00.000
I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat...
0
1
0.024995
0
false
557,241
0
330
5
0
0
557,199
There's no "one size fits all" answer for this -- it'll depend a lot on the data and how it's used in the application. If the data and usage are simple enough you might want to store your fruit in a dict with id as key and the rest of the data as tuples. Or not. It totally depends. If there's a guiding principle out th...
1
0
0
Converting a database-driven (non-OO) python script into a non-database driven, OO-script
8
python,object
0
2009-02-17T14:56:00.000
I have some software that is heavily dependent on MySQL, and is written in python without any class definitions. For performance reasons, and because the database is really just being used to store and retrieve large amounts of data, I'd like to convert this to an object-oriented python script that does not use the dat...
0
2
0.049958
0
false
557,291
0
330
5
0
0
557,199
Generally you want your Objects to absolutely match your "real world entities". Since you're starting from a database, it's not always the case that the database has any real-world fidelity, either. Some database designs are simply awful. If your database has reasonable models for Fruit, that's where you start. Get t...
1
0
0
Converting a database-driven (non-OO) python script into a non-database driven, OO-script
8
python,object
0
2009-02-17T14:56:00.000
I want to experiment/play around with non-relational databases, it'd be best if the solution was: portable, meaning it doesn't require an installation. ideally just copy-pasting the directory to someplace would make it work. I don't mind if it requires editing some configuration files or running a configuration tool f...
2
4
0.088656
0
false
575,197
0
3,510
1
0
0
575,172
If you're used to thinking a relational database has to be huge and heavy like PostgreSQL or MySQL, then you'll be pleasantly surprised by SQLite. It is relational, very small, uses a single file, has Python bindings, requires no extra priviledges, and works on Linux, Windows, and many other platforms.
1
0
0
portable non-relational database
9
python,non-relational-database,portable-database
0
2009-02-22T16:31:00.000
I don't expect to need much more than basic CRUD type functionality. I know that SQLAlchemy is more flexible, but the syntax etc of sqlobject just seem to be a bit easier to get up and going with.
14
9
1
0
false
592,348
0
3,351
1
0
0
592,332
I think SQLObject is more pythonic/simpler, so if it works for you, then stick with it. SQLAlchemy takes a little more to learn, but can do more advanced things if you need that.
1
0
0
Any reasons not to use SQLObject over SQLAlchemy?
3
python,orm,sqlalchemy,sqlobject
0
2009-02-26T20:37:00.000
I am working on ajax-game. The abstract: 2+ gamers(browsers) change a variable which is saved to DB through json. All gamers are synchronized by javascript-timer+json - periodically reading that variable from DB. In general, all changes are stored in DB as history, but I want the recent change duplicated in memory. S...
0
0
0
0
false
603,637
1
127
1
0
0
602,030
You'd either have to use a cache, or fetch the most recent change on each request (since you can't persist objects between requests in-memory). From what you describe, it sounds as if it's being hit fairly frequently, so the cache is probably the way to go.
1
0
1
Store last created model's row in memory
4
python,django
0
2009-03-02T11:46:00.000
I am writing a Python (2.5) GUI Application that does the following: Imports from Access to an Sqlite database Saves ui form settings to an Sqlite database Currently I am using pywin32 to read Access, and pysqlite2/dbapi2 to read/write Sqlite. However, certain Qt objects don't automatically cast to Python or Sqlite ...
1
0
0
0
false
608,262
0
241
1
0
0
608,098
When dealing with databases and PyQt UIs, I'll use something similar to model-view-controller model to help organize and simplify the code. View module uses/holds any QObjects that are necessary for the UI contain simple functions/methods for updating your QTGui Object, as well as extracting input from GUI...
1
0
0
What will I lose or gain from switching database APIs? (from pywin32 and pysqlite to QSql)
1
python,qt,sqlite,pyqt4,pywin32
0
2009-03-03T20:45:00.000