I have a model called user which has_one email. I put the foreign key (NOT NULL) inside users table.
Now I'm trying to save it in the following way:
@email = Email.new(params[:email])
@email.user = User.new(params[:user])
@email.save
This raises a db exception, because the foreign key constraint is not met (NULL is inserted into email_id). How can I elegantly solve this or is my data modeling wrong?
I am using an ASP page where I have to read a CSV file and insert it into DB table "Employee". I am creating an object of TestReader. How can I write a loop to execute up to the number of rows/records of the CSV file which is being read?
In the document, it mentions that we can have a dispatch interval such that page view will be automatically dispatched after x seconds.
I have the code like the following
tracker.startNewSession("UA-YOUR-ACCOUNT-HERE", 20, this);
I sure trackPageView() is called as I can see those pageview are stored into "google_analytics.db" which is the database that google analyitcs used to store non-dispatching pageview. However, it doesn't send to Google Analytics after 20 seconds
In log, it keeps reporting scheduling next dispatch when I call trackPageView().
I have three tables, Customers, Sales and Products.
Sales links a CustomerID with a ProductID and has a SalesPrice.
select Products.Category, AVG(SalePrice) from Sales
inner join Products on Products.ProductID = Sales.ProductID
group by Products.Category
This lets me see the average price for all sales by category. However, I only want to include customers that have more than 3 sales records or more in the DB.
I am not sure the best way, or any way, to go about this. Ideas?
i am trying to login and want to validate username and password against the records in the database. I am not sure how to pass two Where clause
public Boolean login(String username, String password) throws SQLException {
Cursor mCursor = db.query(TABLE_USERS, new String[] { ID,
KEY_NAME, KEY_USERNAME}, KEY_USERNAME + "="
+ "'"+username+"'", KEY_PASSWORD + "="
+ "'"+password+"'", null, null, null, null, null);
if (mCursor.moveToFirst()) {
return true;
}
return false;
}
Am getting a Syntax Error.
I have a DB schema composed of MYISAM tables, i am interested to delete old records from time to time from some of the tables.
I know that delete does not reclaim the memory space, but as i found in a description of DELETE command, inserts may reuse the space deleted
In MyISAM tables, deleted rows are maintained in a linked list and subsequent INSERT operations reuse old row positions.
I am interested if LOAD DATA command also reuses the deleted space?
UPDATE
I am also interested how the index space reclaimed?
string createTable = "CREATE TABLE IF NOT EXISTS " + m_strDatabase + "_TimeLogs (logName VARCHAR(16), logTime INTEGER, logCountry TEXT, UNIQUE(logName)) TYPE=MyISAM;";
When this runs, no table is created.
No errors either.
Im using an ODBC connector.
the variable passes in the db name, so that the table created would be users_TimeLogs if the database was called users for example.
Am I doing something wrong?
Hi guys,
I am a newbee to django and jython. I need to create and save image thumbnails in database. I am using django running on jython and mysql database. I was exploring python imaging library, but the i found out that i wont work with jython.
How do i create image thumbnails using jython and then save them in mysql db?? Any kind of help will be appreciated. thanx
In other words, is the following "cursoring" approach guaranteed to work:
retrieve rows from DB
save the largest ID from the returned records for later, e.g. in LastMax
later, "SELECT * FROM MyTable WHERE Id > {0}", LastMax
In order for that to work, I have to be sure that every row I didn't get in step 1 has an Id greater than LastMax. Is this guaranteed, or can I run into weird race conditions?
After spending some time wireframing my ideas, I want to start building my rails app. However, I'm well aware that later down the line I'd like to consider multiple user accounts.
Should I be thinking about the implementation of this from this early stage, or is this something I can implement without too much fuss later?
It seems like something that would be stupid to attempt later, but part of me just wants to get the guts of the thing working - a couple of simply forms and writing/reading some stuff from the db.
Hi,
i have a large dictionary I'd like to save. I have pickled it using cPickle.dumps and saved the result into a TextField. When trying to retrieve it (cPicle.loads) i get the following error:
loads() argument 1 must be string, not unicode
Does anybody have any experience in serializing python objects and storing them in a DB using Django? Thanks in advance.
Please advise a php framework for fast developing and for don't digress to write often using code(auth, db/orm,etc..).
Requrements:
Active community
Easy to use
simple many to many and many to one relations
auth. mechanism
RoR like
Please sorry for english.
Hi All,
How can we set permissions for users to only allow them to download SSIS packages from the production server and but deny them permissions to run any package in the Server.
http://msdn.microsoft.com/en-us/library/ms141053(SQL.90).aspx
If i assign users to any of the DB roles db_dtsadmin, db_dtsltduser, and db_dtsoperator they will automatically have permission to run the package.
Appreciate your inputs.
Thanks!
How to connect to MYSQL DB from Java, create table, insert data, retrieve it with datatypes.
How to make use of the data to/from in Flex application.
plz help me out..
i have basic knowledge in sending and receiving messages using BlazeDS.
and calling JAVA METHODS USING ...
Hi,
I had a problem where I was using the hibernate template to do most of my DB work but I had a part of the system that directly accessed the session to do batch persisting. I noticed that the hibernate template session was old and would be storing cached values which didnt take into account the objects save with the session directly.
What are the drawbacks of using alwaysUseNewSession? This fixes the problem as I always get up-to-date objects.
Thanks.
I have a client supplied file that is loaded in to our SQL Server database. This file contains text based date values i.e. (05102010) and I need to read them from a db column and convert them to a normal date time value = '2010-05-10 00:00:00.000' as part of a clean-up process.
Any guidance would be greatly appreciated.
I'm working on an application in C# with .Net 3.5. I have time zone value of the User is stored in DB with this format (-05:00,1), where -5.00 represents EST time zone value and the 1 indicates that this time zone follows daylight saving (if 0 not a daylight saving zone).
Now I want to convert any date time value into this timezone value considering the daylight saving value.
Any help is appreciated. Thanks
Currently there is discussion as to what are the pros and cons of having a single sql connection architecture.
To elaborate what we are discussing is, at application creation open a sql connection and at application close or error closing the sql connection. And not creating another connection at all, but using just that one to talk with the DB.
We are wondering what the community thinks.
This line:
used_emails = [row.email for row
in db.execute(select([halo4.c.email], halo4.c.email!=''))]
Returns:
['[email protected]', '[email protected]', '[email protected]', '[email protected]', '[email protected]']
I use this to find a match:
if recipient in used_emails:
If it finds a match I need to pull another field (halo4.c.code) from the database in the same row. Any suggestions on how to do this?
How to make the use of hidden variables as array for consecutive submission of data so that they can be used to display the records list.
I have a form with 4 text fields and a file upload field.. as i submit he form it should get appended to the list which needs to be displayed below the form, such that these values are NOT stored in the DB..
So in this case how can i use the post array to collect the data and display in the list below?
I have a form with multiple fields in it along with a image input field, just below the form i have a list to be displayed on every submit of this form... this has to be done without the use of DB..
I think this can be achieved by using session but its not working with me, as evrytime page gets refreshed and session gets recreated/reset..
Please help me in resolving this issue
What is the common way of dealing with the development.sqlite3 files with VCS (in particular, git)?
If I commit this file to the VCS, will it be merged with another developer's copy?
Or should each developer run the db:migrate task each time a new migration file is created?
Hi,
I want to integrate the dhtmlxScheduler calender with the codeigniter framework. but i am not sure how to connect with the model instead of the db directly and also, how to manage the interaction between the controller, the model and interface
thanks,
I couldn't figure out how to cleanly do a tag cloud with JPA where each db entity can have many tags.
E.g
Post can have 0 or more Tags
User can have 0 or more Tags
Is there a better way in JPA than having to make all the entities subclass something like Taggable abstract class? Where a a Tag entity would reference many Taggables.
thank you